arcpy.MakeFeatureLayer
and 'arcpy.CopyFeatures` geoprocesses.selectList = []
fip = '13245'
for fc in featureclasses:
select = arcpy.MakeFeatureLayer_management(fc, "temp_lyr","FIPS_CODE = '{}'".format(fip))
arcpy.env.workspace = "C:/Workspace/Sandbox/selects.gdb"
selectFeatures = arcpy.CopyFeatures_management(select, "select_{}".format(fip))
selectList.append(selectFeatures)
When I print(selectList)
it gives me a weird list of results:
[<Result'C:\\Workspace\\Sandbox\\MapChangeProject\\selects.gdb\\select_13245'>, <Result 'C:\\Workspace\\Sandbox\\MapChangeProject\\selects.gdb\\select_06037'>]
What I want to do is merge all of these results together into one feature like this:
arcpy.Merge_management(selectList, "merge")
What am I doing wrong here and how do I get my results into a format that will work for my merge?
Solved! Go to Solution.
Please format your code so it's not single-line: /blogs/dan_patterson/2016/08/14/script-formatting
selectList = []
fip = '13245'
for fc in featureclasses:
select = arcpy.MakeFeatureLayer_management(fc, "temp_lyr","FIPS_CODE = '{}'".format(fip))
arcpy.env.workspace = "C:/Workspace/Sandbox/selects.gdb"
selectFeatures = arcpy.CopyFeatures_management(select, "select_{}".format(fip))
selectList.append(selectFeatures)
See here for using geoprocessing result objects: Using tools in Python—Help | ArcGIS Desktop
I'm guessing you want to use:
selectList.append(selectFeatures[0])
# or
selectList.append(selectFeatures.getOutput())
Please format your code so it's not single-line: /blogs/dan_patterson/2016/08/14/script-formatting
selectList = []
fip = '13245'
for fc in featureclasses:
select = arcpy.MakeFeatureLayer_management(fc, "temp_lyr","FIPS_CODE = '{}'".format(fip))
arcpy.env.workspace = "C:/Workspace/Sandbox/selects.gdb"
selectFeatures = arcpy.CopyFeatures_management(select, "select_{}".format(fip))
selectList.append(selectFeatures)
See here for using geoprocessing result objects: Using tools in Python—Help | ArcGIS Desktop
I'm guessing you want to use:
selectList.append(selectFeatures[0])
# or
selectList.append(selectFeatures.getOutput())
Most geoprocessing tools return a Result—Help | ArcGIS Desktop object, which explains why you see "<Result'..." in the list.