Export Layer within Group after network analyst Solve

06-17-2016 08:26 AM
New Contributor II

I would like to write a looping script which solves an x minute catchment in Network Analyst and then exports it to a shapefile. I am trying to get one iteration to work at first and following example #3 ArcGIS help file:

Add Locations—ArcGIS Pro | ArcGIS for Desktop

It's possible the export solution as a group .lyr file (layer_object.saveACopy(output_layer_file)) but I can't understand how to grab one of the children of the group lyr (polygons) and export it to polygons. Layers are often items without attributes, but these produced by NA do have them and are easy to export in ArcMap (right click=> export). In arcpy, CopyFeatures and FeatureLayer do not work seem to work grouped layers.

I have tried

for lyr in ListLayers(layer): 

but get the error

'str' object has no attribute '_arc_object'

Tags (2)
0 Kudos
3 Replies
Esri Regular Contributor

Hello, William.  You're on the right track, but your syntax isn't quite right.  You need to use listLayers more like this:


Check out the code sample on this page for something closer to what you're trying to do: Make Service Area Analysis Layer—ArcGIS Pro | ArcGIS for Desktop

New Contributor II

Hi Melinda --

Thanks for the quick reply. I am looking at it again today and I still get the error:

'Layer' object has no attribute 'listLayers'

But I've also just realized that the Pro help documentation and ArcMap are not interchangable -- the use of arcpy is not the same. In ArcMap you need to pass a map document into listlayers. So I will try again with the right documentation

0 Kudos
MVP Esteemed Contributor

the arcpy documentation for NA for arcmap begins here

What is the Network Analyst module?—Help | ArcGIS for Desktop

and code examples are contained with eg.

GetSolverProperties—Help | ArcGIS for Desktop  which references the sublayers issue

0 Kudos