<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Error when saving Network Analyst service area sub-layer as shapefile using Arcpy in ArcGIS Network Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-network-analyst-questions/error-when-saving-network-analyst-service-area-sub/m-p/1099023#M7644</link>
    <description>&lt;P&gt;Retrieving an NA layer's sublayer is a common workflow in standalone python, and it is admittedly not obvious how to do it.&lt;/P&gt;&lt;P&gt;First, I will assume you're using ArcMap or 10.x Server since you're working with .lyr files. So, my response here is appropriate for ArcMap and not Pro.&lt;/P&gt;&lt;P&gt;The first problem is that the SelectData utility is a Model Builder utility only and should not be called from standalone python. It just doesn't work.&lt;/P&gt;&lt;P&gt;I think something like this will work:&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;layer_object = arcpy.mapping.Layer(&lt;SPAN&gt;FireStationCoverage&lt;/SPAN&gt;&lt;SPAN&gt;_lyr&lt;/SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;polygons_sublayer =&lt;/SPAN&gt; &lt;SPAN class=""&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;mapping&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;ListLayers&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;SPAN class=""&gt;layer_object&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt;&amp;nbsp;"Polygons"&lt;SPAN class=""&gt;)[&lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN class=""&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;arcpy.management.CopyFeatures(&lt;SPAN class=""&gt;polygons_sublayer&lt;/SPAN&gt;, out_featureclass)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Note that if you switch to Pro, you can use the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/getnasublayer.htm" target="_self"&gt;GetNASublayer function&lt;/A&gt; for a much less confusing experience. If you are doing a full Network Analyst workflow, there are actually much better and faster ways to do it in Pro using the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/performing-network-analysis.htm" target="_self"&gt;arcpy.nax module&lt;/A&gt;, which eliminates the need for NA layers entirely.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Sep 2021 18:21:32 GMT</pubDate>
    <dc:creator>MelindaMorang</dc:creator>
    <dc:date>2021-09-16T18:21:32Z</dc:date>
    <item>
      <title>Error when saving Network Analyst service area sub-layer as shapefile using Arcpy</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/error-when-saving-network-analyst-service-area-sub/m-p/1098963#M7643</link>
      <description>&lt;P&gt;I am using python to save the service area polygons from a Network Analyst layer file as shapefiles but the script fails to execute the copy features function:&lt;/P&gt;&lt;P&gt;ExecuteError: Failed to execute. Parameters are not valid; ERROR 000840: The value is not a Feature Layer; ERROR 000840: The value is not a Raster Catalog Layer; Failed to execute (CopyFeatures)&lt;/P&gt;&lt;P&gt;Can anyone tell me what is wrong with the script?&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Import module&lt;BR /&gt;import arcpy&lt;BR /&gt;import os&lt;/P&gt;&lt;P&gt;# Local variables:&lt;BR /&gt;layer_name = &lt;SPAN&gt;"FireStationCoverage"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FireStationCoverage&lt;/SPAN&gt;_lyr = "C:/Data/&lt;SPAN&gt;FireStationCoverage&lt;/SPAN&gt;.lyr"&lt;BR /&gt;Polygons = &lt;SPAN&gt;FireStationCoverage_lyr&lt;/SPAN&gt;&lt;BR /&gt;output_dir = "C:/Data/poly_output"&lt;BR /&gt;out_featureclass = os.path.join(output_dir,layer_name)&lt;/P&gt;&lt;P&gt;# Process: Select Data&lt;BR /&gt;arcpy.SelectData_management(&lt;SPAN&gt;FireStationCoverage&lt;/SPAN&gt;, "Polygons")&lt;BR /&gt;print "data selected"&lt;/P&gt;&lt;P&gt;# Process: Feature Class to Feature Class&lt;BR /&gt;arcpy.management.CopyFeatures(Polygons, out_featureclass)&lt;BR /&gt;print "data saved"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2021 16:16:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/error-when-saving-network-analyst-service-area-sub/m-p/1098963#M7643</guid>
      <dc:creator>SG_Johnson</dc:creator>
      <dc:date>2021-09-16T16:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Error when saving Network Analyst service area sub-layer as shapefile using Arcpy</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/error-when-saving-network-analyst-service-area-sub/m-p/1099023#M7644</link>
      <description>&lt;P&gt;Retrieving an NA layer's sublayer is a common workflow in standalone python, and it is admittedly not obvious how to do it.&lt;/P&gt;&lt;P&gt;First, I will assume you're using ArcMap or 10.x Server since you're working with .lyr files. So, my response here is appropriate for ArcMap and not Pro.&lt;/P&gt;&lt;P&gt;The first problem is that the SelectData utility is a Model Builder utility only and should not be called from standalone python. It just doesn't work.&lt;/P&gt;&lt;P&gt;I think something like this will work:&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;layer_object = arcpy.mapping.Layer(&lt;SPAN&gt;FireStationCoverage&lt;/SPAN&gt;&lt;SPAN&gt;_lyr&lt;/SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;polygons_sublayer =&lt;/SPAN&gt; &lt;SPAN class=""&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;mapping&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;ListLayers&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;SPAN class=""&gt;layer_object&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt;&amp;nbsp;"Polygons"&lt;SPAN class=""&gt;)[&lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN class=""&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;arcpy.management.CopyFeatures(&lt;SPAN class=""&gt;polygons_sublayer&lt;/SPAN&gt;, out_featureclass)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Note that if you switch to Pro, you can use the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/getnasublayer.htm" target="_self"&gt;GetNASublayer function&lt;/A&gt; for a much less confusing experience. If you are doing a full Network Analyst workflow, there are actually much better and faster ways to do it in Pro using the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/performing-network-analysis.htm" target="_self"&gt;arcpy.nax module&lt;/A&gt;, which eliminates the need for NA layers entirely.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2021 18:21:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/error-when-saving-network-analyst-service-area-sub/m-p/1099023#M7644</guid>
      <dc:creator>MelindaMorang</dc:creator>
      <dc:date>2021-09-16T18:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Error when saving Network Analyst service area sub-layer as shapefile using Arcpy</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/error-when-saving-network-analyst-service-area-sub/m-p/1099289#M7645</link>
      <description>&lt;P&gt;Thank you very much! You have got the script working for me!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 07:22:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/error-when-saving-network-analyst-service-area-sub/m-p/1099289#M7645</guid>
      <dc:creator>SG_Johnson</dc:creator>
      <dc:date>2021-09-17T07:22:58Z</dc:date>
    </item>
  </channel>
</rss>

