1

I have a script tool that:

  • Creates a feature dataset within a file geodatabase
  • Performs a Select by Attributes on a cadastral layer
  • Copies the selected polygons into the feature dataset.
  • The copied polygons are then dissolved to give a property boundary and added to the feature dataset
  • The centroid is then calculated and added to the feature dataset

Now this works fine the first time you run the script. But once you run it for a new property I get the 000210 error whilst trying to copy the selected polygons into the feature dataset. It will create the new feature dataset, but it will not let me copy anything into it. I have tried using personal geodatabases. I have tried outputting to a shapefile and using FeatureClassToGeodatabase tool, all which do not work. BUT if I delete all other feature datasets then it will work. I've checked for locks and there are none. I do not understand what could possibly be going on here

import arcpy, os

#Specify the drive you have stored the NCT_GIS foler on
drive = arcpy.GetParameterAsText(0)

#Folders
RF_Prop_DB = drive + ":\\NCT_GIS\\DATA\\RF_Properties.gdb"
Lambert_Projection = drive +":\\NCT_GIS\\Scripts\\res\\GDA 1994 New South Wales Lambert.prj"

arcpy.env.workspace = (RF_Prop_DB)
arcpy.env.overwriteOutput = True
lot_DP = arcpy.GetParameterAsText(1).split(';')
PropertyName = arcpy.GetParameterAsText(2)
#Create the query
queryList= []
for i in range(0,len(lot_DP)):
    if i % 2 == 0:
        lt = lot_DP[i]
        DP = lot_DP[i+1]
        query_line = """( "LOTNUMBER" = '{0}' AND "PLANNUMBER" = {1} )""".format(lt, DP)
        queryList.append(query_line)
        if i < (len(lot_DP)):
           queryList.append(" OR ")
del queryList[len(queryList)-1]        
query = ''.join(queryList)


#Create the feature dataset for the property
arcpy.CreateFeatureDataset_management(RF_Prop_DB, PropertyName, Lambert_Projection)
#Cadastre
lotFile = drive + ":\\NCT_GIS\\DATA\\NSWData.gdb\\Admin\\cadastre"
#Create lot polygons in feature dataset
arcpy.MakeFeatureLayer_management(lotFile, "lot_lyr") 
arcpy.SelectLayerByAttribute_management("lot_lyr", "NEW_SELECTION", query)
arcpy.CopyFeatures_management("lot_lyr", os.path.join(RF_Prop_DB, PropertyName, "Lots"))
#Create property boundary in feature dataset
arcpy.Dissolve_management(os.path.join(RF_Prop_DB, PropertyName, "Lots") , os.path.join(RF_Prop_DB, PropertyName, "Boundary"), "", "", "SINGLE_PART", "DISSOLVE_LINES")
#Create property centroid in feature dataset
arcpy.FeatureToPoint_management(os.path.join(RF_Prop_DB, PropertyName, "Boundary"), os.path.join(RF_Prop_DB, PropertyName, "Centroid"), "CENTROID")
2

Browse other questions tagged or ask your own question.