<?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 Route Layer from Closest Facility using Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/export-route-layer-from-closest-facility-using/m-p/624226#M48674</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually I am trying to automate the workflow of finding closest facility in a network dataset, mostly following help file. This is my work flow&lt;/P&gt;&lt;P&gt;1) Make Closest Facility Layer - arcpy.MakeClosestFacilityLayer_na&lt;/P&gt;&lt;P&gt;2) Add Facility Locations - arcpy.AddLocations_na&lt;/P&gt;&lt;P&gt;3) Add Incident Locations - arcpy.AddLocations_na&lt;/P&gt;&lt;P&gt;4) Solve - arcpy.Solve_na&lt;/P&gt;&lt;P&gt;5) Save to Layer File&amp;nbsp; -&amp;nbsp; arcpy.management.SaveToLayerFile&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This flow creates a layer file as first output itself (the one that I am&amp;nbsp; trying to export as a feature class - "&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;Closest_NationalParks_Facility"). &lt;/SPAN&gt;I do not know a way of avoiding layer creation at the first place for closest facility analysis.&lt;/P&gt;&lt;P&gt;Please let me know if there is another way of doing it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Apr 2015 09:16:53 GMT</pubDate>
    <dc:creator>PriyankaMehta</dc:creator>
    <dc:date>2015-04-21T09:16:53Z</dc:date>
    <item>
      <title>Export Route Layer from Closest Facility using Python</title>
      <link>https://community.esri.com/t5/python-questions/export-route-layer-from-closest-facility-using/m-p/624224#M48672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt; How should I export route layer that is a part of closest facility layer.&lt;/P&gt;&lt;P&gt;It works with the model builder if I use "Select Data" followed by Copy Features but if I even save that model builder as python script , it does not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;This is the exported python script from model builder
# Local variables:
Closest_NationalParks_Facility = "Closest_NationalParks_Facility"
Routes__2_ = "C:\\Projects\\RAFT\\Closest_NationalParks_Punggol\\Routes"
CFRoutes_CopyFeatures = "C:\\Users\\mehtap\\Documents\\ArcGIS\\Default.gdb\\CFRoutes_CopyFeatures"
# Process: Select Data
arcpy.SelectData_management(Closest_NationalParks_Facility, "Routes")
# Process: Copy Features
arcpy.CopyFeatures_management(Routes__2_, CFRoutes_CopyFeatures, "", "0", "0", "0")&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It does not recognize Closest_NationalParks_Facility as a dataset at the first place and gives this error&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;"ERROR 000732: Input Data Element: Dataset Closest_NationalParks_Facility does not exist or is not supported"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I tried modifying it by adding ".lyr" to the input. It can do select data with that but still not copy features.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Local variables:
Closest_NationalParks_Facility = "C:\\Projects\\RAFT\\Closest_NationalParks_Facility.lyr"
CFRoutes_CopyFeatures = "C:\\Users\\mehtap\\Documents\\ArcGIS\\Default.gdb\\CFRoutes_CopyFeatures2"
# Process: Select Data
sel = arcpy.SelectData_management(Closest_NationalParks_Facility, "Routes")
# Process: Copy Features
arcpy.CopyFeatures_management(sel, CFRoutes_CopyFeatures, "", "0", "0", "0")&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"sel" returns : &lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; sel
&amp;lt;Result 'C:\\Projects\\RAFT\\Closest_NationalParks_Facility.lyr\\Closest_NationalParks_Facility\\Routes'&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I cannot understand how to make "Routes" sub layer be recognized or anyhow export Route layer to geodatabase.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Priyanka Mehta&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:35:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-route-layer-from-closest-facility-using/m-p/624224#M48672</guid>
      <dc:creator>PriyankaMehta</dc:creator>
      <dc:date>2021-12-12T02:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: Export Route Layer from Closest Facility using Python</title>
      <link>https://community.esri.com/t5/python-questions/export-route-layer-from-closest-facility-using/m-p/624225#M48673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If think you should first tell python where's the location of your Closest_Facility feature class, and then create a lyr out of that. Without python can't find the feature layer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2015 09:01:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-route-layer-from-closest-facility-using/m-p/624225#M48673</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2015-04-21T09:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: Export Route Layer from Closest Facility using Python</title>
      <link>https://community.esri.com/t5/python-questions/export-route-layer-from-closest-facility-using/m-p/624226#M48674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually I am trying to automate the workflow of finding closest facility in a network dataset, mostly following help file. This is my work flow&lt;/P&gt;&lt;P&gt;1) Make Closest Facility Layer - arcpy.MakeClosestFacilityLayer_na&lt;/P&gt;&lt;P&gt;2) Add Facility Locations - arcpy.AddLocations_na&lt;/P&gt;&lt;P&gt;3) Add Incident Locations - arcpy.AddLocations_na&lt;/P&gt;&lt;P&gt;4) Solve - arcpy.Solve_na&lt;/P&gt;&lt;P&gt;5) Save to Layer File&amp;nbsp; -&amp;nbsp; arcpy.management.SaveToLayerFile&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This flow creates a layer file as first output itself (the one that I am&amp;nbsp; trying to export as a feature class - "&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;Closest_NationalParks_Facility"). &lt;/SPAN&gt;I do not know a way of avoiding layer creation at the first place for closest facility analysis.&lt;/P&gt;&lt;P&gt;Please let me know if there is another way of doing it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2015 09:16:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-route-layer-from-closest-facility-using/m-p/624226#M48674</guid>
      <dc:creator>PriyankaMehta</dc:creator>
      <dc:date>2015-04-21T09:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: Export Route Layer from Closest Facility using Python</title>
      <link>https://community.esri.com/t5/python-questions/export-route-layer-from-closest-facility-using/m-p/624227#M48675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As I mentioned you have to define your feature class first, before you can make a layer file.&lt;/P&gt;&lt;P&gt;So simply write:&lt;/P&gt;&lt;P&gt;Closest_NationalParks_Facility = &lt;SPAN class="string"&gt;"YourPathtotheFeatureClass"&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2015 10:26:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-route-layer-from-closest-facility-using/m-p/624227#M48675</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2015-04-21T10:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Export Route Layer from Closest Facility using Python</title>
      <link>https://community.esri.com/t5/python-questions/export-route-layer-from-closest-facility-using/m-p/624228#M48676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, Priyanka.&amp;nbsp; Accessing the NA sublayers in python can be a little tricky.&amp;nbsp; The Select Data tool is a Model-Builder-only tool.&amp;nbsp; You have to play with layer objects when you're using python.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The best thing for you to do is to look at the last code sample on this page: &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#/Make_Route_Layer/00480000000n000000/" title="http://resources.arcgis.com/en/help/main/10.2/index.html#/Make_Route_Layer/00480000000n000000/"&gt;ArcGIS Help (10.2, 10.2.1, and 10.2.2)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It's for the Route solver and not Closest Facility, but it's the same idea.&amp;nbsp; The OD Cost Matrix and Service Area doc pages also have similar samples that might help. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2015 15:14:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-route-layer-from-closest-facility-using/m-p/624228#M48676</guid>
      <dc:creator>MelindaMorang</dc:creator>
      <dc:date>2015-04-21T15:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Export Route Layer from Closest Facility using Python</title>
      <link>https://community.esri.com/t5/python-questions/export-route-layer-from-closest-facility-using/m-p/624229#M48677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a ton Melinda ! This is exactly what I needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Priyanka&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Apr 2015 02:06:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-route-layer-from-closest-facility-using/m-p/624229#M48677</guid>
      <dc:creator>PriyankaMehta</dc:creator>
      <dc:date>2015-04-22T02:06:43Z</dc:date>
    </item>
  </channel>
</rss>

