<?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: Export Line and Polygon from Network Analyst Service Layer in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/export-line-and-polygon-from-network-analyst/m-p/1544703#M72973</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/25971"&gt;@ColeNelson&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I recently having the same issue using arcpy.na, however, you can do this using arcpy.&lt;STRONG&gt;nax.&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;Here is a great sample that shows how to export polygons from a service area:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/servicearea.htm#C_GUID-A2ABB768-1B6A-45D3-A1EA-F2A32BFCB921" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/servicearea.htm#C_GUID-A2ABB768-1B6A-45D3-A1EA-F2A32BFCB921&lt;/A&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# Export the results to a feature class
if result.solveSucceeded:
    result.export(arcpy.nax.ServiceAreaOutputDataType.Polygons, output_polygons)&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 02 Oct 2024 12:55:36 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2024-10-02T12:55:36Z</dc:date>
    <item>
      <title>Export Line and Polygon from Network Analyst Service Layer</title>
      <link>https://community.esri.com/t5/python-questions/export-line-and-polygon-from-network-analyst/m-p/1543525#M72955</link>
      <description>&lt;P&gt;Hello, I am trying to write a code that will generate 4 Network Service Analyst Layers for 1.5, 2.5, 5, and 7 miles.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then be able to extract the lines and polygons from each of those service layers, and save each of them as their own individual feature classes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now I have the code written to generate each service analysis layer successfully, but have yet to figure out how to extract and create the individual features.&lt;/P&gt;&lt;P&gt;Here is the code so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

arcpy.env.overwriteOutput = True
arcpy.env.workspace =  r"C:\PPCAnalysis\PPCAnalyis\PPCAnalyis.gdb"

stationSelect = arcpy.GetParameterAsText(0).split(";")
createServiceArea = arcpy.GetParameterAsText(1).split(";")

stationFeatures = "FireStations"
Streetmap = r"C:\GIS\Streetmap Premium\FGDB\StreetMap_Data\NorthAmerica.gdb\Routing\Routing_ND"
qry = "{0} IN ({1})".format(arcpy.AddFieldDelimiters(datasource= stationFeatures, field = 'StationID'), ', '.join(stationSelect))

#Select the hydrants by WaterSysID
arcpy.SelectLayerByAttribute_management(in_layer_or_view=stationFeatures, where_clause=qry)

if '1.5' in createServiceArea:
    mile_Half_Service = arcpy.na.MakeServiceAreaAnalysisLayer(
                        network_data_source=Streetmap,
                        layer_name="Service Area",
                        travel_mode="Driving Distance",
                        travel_direction="FROM_FACILITIES",
                        cutoffs=[2.41402],
                        time_of_day=None,
                        time_zone="LOCAL_TIME_AT_LOCATIONS",
                        output_type="POLYGONS_AND_LINES",
                        polygon_detail="STANDARD",
                        geometry_at_overlaps="OVERLAP",
                        geometry_at_cutoffs="RINGS",
                        polygon_trim_distance="100 Meters",
                        exclude_sources_from_polygon_generation=None,
                        accumulate_attributes=None,
                        ignore_invalid_locations="SKIP")
    
    updated_Mile_Half = arcpy.na.AddLocations(
                        in_network_analysis_layer= mile_Half_Service,
                        sub_layer="Facilities",
                        in_table= stationFeatures,
                        field_mappings="Name Address #;CurbApproach # 0;Attr_Minutes # 0;Attr_TravelTime # 0;Attr_Miles # 0;Attr_Kilometers # 0;Attr_TimeAt1KPH # 0;Attr_WalkTime # 0;Attr_TruckMinutes # 0;Attr_TruckTravelTime # 0;Breaks_Minutes # #;Breaks_TravelTime # #;Breaks_Miles # #;Breaks_Kilometers # #;Breaks_TimeAt1KPH # #;Breaks_WalkTime # #;Breaks_TruckMinutes # #;Breaks_TruckTravelTime # #",
                        search_tolerance="5000 Meters",
                        sort_field=None,
                        search_criteria="Routing_Streets SHAPE;Routing_Streets_Override NONE;Routing_ND_Junctions NONE",
                        match_type="MATCH_TO_CLOSEST",
                        append="APPEND",
                        snap_to_position_along_network="NO_SNAP",
                        snap_offset="5 Meters",
                        exclude_restricted_elements="EXCLUDE",
                        search_query=None,
                        allow_auto_relocate="ALLOW")
    
    solve_Mile_Half = arcpy.na.Solve(
                        in_network_analysis_layer= updated_Mile_Half,
                        ignore_invalids="SKIP",
                        terminate_on_solve_error="TERMINATE",
                        simplification_tolerance=None,
                        overrides="")
    



    arcpy.AddMessage("1.5 mile service area was successfully created")

else:
    arcpy.AddMessage('Did not select 1.5')

if '2.5' in createServiceArea:
    two_Half_Service = arcpy.na.MakeServiceAreaAnalysisLayer(
                        network_data_source=Streetmap,
                        layer_name="Service Area",
                        travel_mode="Driving Distance",
                        travel_direction="FROM_FACILITIES",
                        cutoffs=[4.02336],
                        time_of_day=None,
                        time_zone="LOCAL_TIME_AT_LOCATIONS",
                        output_type="POLYGONS_AND_LINES",
                        polygon_detail="STANDARD",
                        geometry_at_overlaps="OVERLAP",
                        geometry_at_cutoffs="RINGS",
                        polygon_trim_distance="100 Meters",
                        exclude_sources_from_polygon_generation=None,
                        accumulate_attributes=None,
                        ignore_invalid_locations="SKIP")
    
    updated_Two_Half = arcpy.na.AddLocations(
                        in_network_analysis_layer= two_Half_Service,
                        sub_layer="Facilities",
                        in_table= stationFeatures,
                        field_mappings="Name Address #;CurbApproach # 0;Attr_Minutes # 0;Attr_TravelTime # 0;Attr_Miles # 0;Attr_Kilometers # 0;Attr_TimeAt1KPH # 0;Attr_WalkTime # 0;Attr_TruckMinutes # 0;Attr_TruckTravelTime # 0;Breaks_Minutes # #;Breaks_TravelTime # #;Breaks_Miles # #;Breaks_Kilometers # #;Breaks_TimeAt1KPH # #;Breaks_WalkTime # #;Breaks_TruckMinutes # #;Breaks_TruckTravelTime # #",
                        search_tolerance="5000 Meters",
                        sort_field=None,
                        search_criteria="Routing_Streets SHAPE;Routing_Streets_Override NONE;Routing_ND_Junctions NONE",
                        match_type="MATCH_TO_CLOSEST",
                        append="APPEND",
                        snap_to_position_along_network="NO_SNAP",
                        snap_offset="5 Meters",
                        exclude_restricted_elements="EXCLUDE",
                        search_query=None,
                        allow_auto_relocate="ALLOW")
    
    solve_Two_Half = arcpy.na.Solve(
                        in_network_analysis_layer= updated_Two_Half,
                        ignore_invalids="SKIP",
                        terminate_on_solve_error="TERMINATE",
                        simplification_tolerance=None,
                        overrides="")
    arcpy.AddMessage("2.5 mile service area was successfully created")
   
else:
    arcpy.AddMessage('Did not select 2.5')

if '5' in createServiceArea:
    five_Service = arcpy.na.MakeServiceAreaAnalysisLayer(
                        network_data_source=Streetmap,
                        layer_name="Service Area",
                        travel_mode="Driving Distance",
                        travel_direction="FROM_FACILITIES",
                        cutoffs=[8.04672],
                        time_of_day=None,
                        time_zone="LOCAL_TIME_AT_LOCATIONS",
                        output_type="POLYGONS_AND_LINES",
                        polygon_detail="STANDARD",
                        geometry_at_overlaps="OVERLAP",
                        geometry_at_cutoffs="RINGS",
                        polygon_trim_distance="100 Meters",
                        exclude_sources_from_polygon_generation=None,
                        accumulate_attributes=None,
                        ignore_invalid_locations="SKIP")
    
    updated_Five = arcpy.na.AddLocations(
                        in_network_analysis_layer= five_Service,
                        sub_layer="Facilities",
                        in_table= stationFeatures,
                        field_mappings="Name Address #;CurbApproach # 0;Attr_Minutes # 0;Attr_TravelTime # 0;Attr_Miles # 0;Attr_Kilometers # 0;Attr_TimeAt1KPH # 0;Attr_WalkTime # 0;Attr_TruckMinutes # 0;Attr_TruckTravelTime # 0;Breaks_Minutes # #;Breaks_TravelTime # #;Breaks_Miles # #;Breaks_Kilometers # #;Breaks_TimeAt1KPH # #;Breaks_WalkTime # #;Breaks_TruckMinutes # #;Breaks_TruckTravelTime # #",
                        search_tolerance="5000 Meters",
                        sort_field=None,
                        search_criteria="Routing_Streets SHAPE;Routing_Streets_Override NONE;Routing_ND_Junctions NONE",
                        match_type="MATCH_TO_CLOSEST",
                        append="APPEND",
                        snap_to_position_along_network="NO_SNAP",
                        snap_offset="5 Meters",
                        exclude_restricted_elements="EXCLUDE",
                        search_query=None,
                        allow_auto_relocate="ALLOW")
    
    solve_Five = arcpy.na.Solve(
                        in_network_analysis_layer= updated_Five,
                        ignore_invalids="SKIP",
                        terminate_on_solve_error="TERMINATE",
                        simplification_tolerance=None,
                        overrides="")
    
    arcpy.AddMessage("5 mile service area was successfully created")

else:
    arcpy.AddMessage('Did not select 5')

if '7' in createServiceArea:
    seven_Service = arcpy.na.MakeServiceAreaAnalysisLayer(
                        network_data_source=Streetmap,
                        layer_name="Service Area",
                        travel_mode="Driving Distance",
                        travel_direction="FROM_FACILITIES",
                        cutoffs=[11.2654],
                        time_of_day=None,
                        time_zone="LOCAL_TIME_AT_LOCATIONS",
                        output_type="POLYGONS_AND_LINES",
                        polygon_detail="STANDARD",
                        geometry_at_overlaps="OVERLAP",
                        geometry_at_cutoffs="RINGS",
                        polygon_trim_distance="100 Meters",
                        exclude_sources_from_polygon_generation=None,
                        accumulate_attributes=None,
                        ignore_invalid_locations="SKIP")
    
    updated_Seven = arcpy.na.AddLocations(
                        in_network_analysis_layer= seven_Service,
                        sub_layer="Facilities",
                        in_table= stationFeatures,
                        field_mappings="Name Address #;CurbApproach # 0;Attr_Minutes # 0;Attr_TravelTime # 0;Attr_Miles # 0;Attr_Kilometers # 0;Attr_TimeAt1KPH # 0;Attr_WalkTime # 0;Attr_TruckMinutes # 0;Attr_TruckTravelTime # 0;Breaks_Minutes # #;Breaks_TravelTime # #;Breaks_Miles # #;Breaks_Kilometers # #;Breaks_TimeAt1KPH # #;Breaks_WalkTime # #;Breaks_TruckMinutes # #;Breaks_TruckTravelTime # #",
                        search_tolerance="5000 Meters",
                        sort_field=None,
                        search_criteria="Routing_Streets SHAPE;Routing_Streets_Override NONE;Routing_ND_Junctions NONE",
                        match_type="MATCH_TO_CLOSEST",
                        append="APPEND",
                        snap_to_position_along_network="NO_SNAP",
                        snap_offset="5 Meters",
                        exclude_restricted_elements="EXCLUDE",
                        search_query=None,
                        allow_auto_relocate="ALLOW")
    
    solve_Seven = arcpy.na.Solve(
                        in_network_analysis_layer= updated_Seven,
                        ignore_invalids="SKIP",
                        terminate_on_solve_error="TERMINATE",
                        simplification_tolerance=None,
                        overrides="")
    arcpy.AddMessage("7W mile service area was successfully created")

else:
    arcpy.AddMessage('Did not select 7W')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 18:10:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-line-and-polygon-from-network-analyst/m-p/1543525#M72955</guid>
      <dc:creator>ColeNelson</dc:creator>
      <dc:date>2024-09-27T18:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Export Line and Polygon from Network Analyst Service Layer</title>
      <link>https://community.esri.com/t5/python-questions/export-line-and-polygon-from-network-analyst/m-p/1544703#M72973</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/25971"&gt;@ColeNelson&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I recently having the same issue using arcpy.na, however, you can do this using arcpy.&lt;STRONG&gt;nax.&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;Here is a great sample that shows how to export polygons from a service area:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/servicearea.htm#C_GUID-A2ABB768-1B6A-45D3-A1EA-F2A32BFCB921" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/servicearea.htm#C_GUID-A2ABB768-1B6A-45D3-A1EA-F2A32BFCB921&lt;/A&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# Export the results to a feature class
if result.solveSucceeded:
    result.export(arcpy.nax.ServiceAreaOutputDataType.Polygons, output_polygons)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 02 Oct 2024 12:55:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-line-and-polygon-from-network-analyst/m-p/1544703#M72973</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2024-10-02T12:55:36Z</dc:date>
    </item>
  </channel>
</rss>

