Hi all,I'm having a problem removing a join with python code (ArcGIS 10.0). With a python script I'm doing a spatial SORT for a number of polygons which fall within a certain number of regions. Within a function I do the following:
- Create a temporary featureclass as result from the Spatial sort
- Put the value of the ObjectID in a new field
- Add a join between the input layer and the temporary FC
- Calculate the value of the sorted objected for the input FC
- Remove the join
This is the code of the python function.def spatialsort (inlayer, outfc, nutsvalue):
# (temp FC, spatial sort, add field, calc OID, atribuir valor join, ...)
# temp fc Nome
tempfcnome = tempfd + "\\SORT" + nutsvalue
tempfcnome2 = "SORT" + nutsvalue
if gp.Exists(tempfcnome):
gp.Delete_management(tempfcnome, "")
gp.Sort_management(inlayer, tempfcnome, "SHAPE ASCENDING", "PEANO")
# Adicionar campo SORT
gp.AddField_management(tempfcnome, "SORT_TEMP_ID", "LONG", 6)
# Calcular campo
# nao seria necessario pode fazer o calculate a partir OBJECTID original
gp.CalculateField_management(tempfcnome, "SORT_TEMP_ID", "!OBJECTID!","PYTHON")
# Adicionar Join
joinField = "GRD_NEWID"
fieldList = ["SORT_TEMP_ID"] # OBJECTID
# criar table view (alternative to using featurelayer):
theDesc = gp.Describe(inlayer)
gp.MakeTableView_management (theDesc.catalogPath, "temptableview")
theDesc = gp.Describe(tempfcnome)
gp.MakeTableView_management (theDesc.catalogPath, "temptableview2")
# Using tableviews
gp.JoinField_management ("temptableview", joinField, "temptableview2", joinField, fieldList) # tempfcnome
Everything works fine except the last step. I tried to remove the join using as input:Using the fullname of the layer:[INDENT]arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid. The value cannot be a feature class[/INDENT]Using only the basename:[INDENT]ERROR 000732: Layer Name or Table View: Dataset TEST2_GRID_1KM_CONT does not exist or is not supported[/INDENT]Using the name of layer (this case gridlayer):[INDENT]arcgisscripting.ExecuteError: ERROR 000229: Cannot open gridlayer[/INDENT]Using tableviews as input, error:[INDENT] gp.RemoveJoin_management ("temptableview", "temptableview2")arcgisscripting.ExecuteError: ERROR 000229: Cannot open temptableview[/INDENT]I checked the following topic http://forums.arcgis.com/threads/13163-arcgis-10-is-there-a-way-to-remove-all-joins-with-python, but this didn�??t offer any solution.Does anyone knows what I�??m doing wrong? Any suggestions for alternative ways?Thank you,Bart Schoenmakers