Using the results of geoprocess in another geoprocess

271
2
Jump to solution
09-05-2018 02:14 PM
JustinBridwell2
Occasional Contributor II
I have a list to hold the iterated results of running 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?

Tags (4)
0 Kudos
1 Solution

Accepted Solutions
DarrenWiens2
MVP Honored Contributor

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())

View solution in original post

2 Replies
DarrenWiens2
MVP Honored Contributor

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())
JoshuaBixby
MVP Esteemed Contributor

Most geoprocessing tools return a Result—Help | ArcGIS Desktop object, which explains why you see "<Result'..." in the list.