While i'am trying to execute this code IN IDLE, i got error :
import arcpy
import math
import arcview
from arcpy import env
arcpy.env.workspace = "D:/Users/saadiya/Documents/ArcGIS/Default.gdb"
arcpy.env.overwriteOutput = True
#Create a table of neighbors
arcpy.PolygonNeighbors_analysis("Parcelles_class_copy","Voisins_table") #Parcelles_class_copy est le résultat de la conversion de dwg en polygon
#Select each table neighbors
for i in range(1,8) :
expression = '"src_OBJECTID"=' + str(i)
output_table = "output_table" + str(i)
arcpy.TableSelect_analysis("Voisins_table", output_table, expression)
#print expression
#***************** supprimer la table Voisins_table **********************************************************************
arcpy.Delete_management("Voisins_table")
#Joint table of neighbors to feautre class
arcpy.AddJoin_management("Parcelles_class_copy","OBJECTID", output_table,"nbr_OBJECTID","KEEP_ALL")
del expression
#Select a target parcel
target_parcel = "target_parcel" + str(i)
whereclause1 = '"Parcelles_class.OBJECTID"=' + str(i)
arcpy.Select_analysis("Parcelles_class_copy",target_parcel,whereclause1)
arcpy.RemoveJoin_management("Parcelles_class_copy",output_table)
i got this error :
ERROR 000840: The value is not a Raster Catalogue Layer
ERROR 000840: The value is not a Raster Layer.
ERROR 000840: The value is not a Mosaic Layer
Failed to execute (Addjoin)
Answer
arcpy.AddJoin_management request a layer !! so i added Makefeature class before AddJoin
arcpy.MakeFeatureLayer_management("Parcelles_class_copy", "tempLayer")
arcpy.AddJoin_management("tempLayer","OBJECTID", output_table,"nbr_OBJECTID","KEEP_ALL")
That fixed the problem.
No comments:
Post a Comment