<?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 How to access Route sublayer properties with ArcPy? in ArcGIS Network Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-network-analyst-questions/how-to-access-route-sublayer-properties-with-arcpy/m-p/456125#M4334</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;After solving a route I need to read the properties of the Route class. Concretely the Total_[Impedance] field as I want to compare different routes with regard to this attribute. Is there any way to do this with ArcPy? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My code until this step is typical:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Courier New;"&gt;route_lyr = arcpy.na.MakeRouteLayer(nwork,"BestRoute", "Length", output_path_shape="TRUE_LINES_WITH_MEASURES")&lt;BR /&gt;route_lyr = route_lyr.getOutput(0)&lt;BR /&gt;sub_layers = arcpy.na.GetNAClassNames(route_lyr)&lt;BR /&gt;arcpy.na.AddLocations("BestRoute",sub_layers["Stops"],"stops.shp")&lt;BR /&gt;arcpy.na.Solve(route_lyr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then I thought about the following to get the Total_Length value of the solve result:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Courier New;"&gt;for lyr in arcpy.mapping.ListLayers(route_lyr):&lt;BR /&gt;[INDENT]if lyr.name == "Routes":[/INDENT]&lt;BR /&gt;[INDENT][INDENT]print lyr.longName&amp;nbsp;&amp;nbsp; ### Printed just for demonstration purposes[/INDENT][/INDENT]&lt;BR /&gt;[INDENT][INDENT]with arcpy.da.SearchCursor(lyr.longName, ['Total_Length']) as cursor:&amp;nbsp; [/INDENT][/INDENT]&lt;BR /&gt;[INDENT][INDENT][INDENT][INDENT]### "BestRoute\Routes" is passed. [/INDENT]&lt;BR /&gt;[/INDENT][/INDENT][/INDENT]&lt;BR /&gt;[INDENT][INDENT][INDENT][INDENT]### The error is thrown here[/INDENT][/INDENT][/INDENT][/INDENT]&lt;BR /&gt;[INDENT][INDENT][INDENT]for row in cursor:[/INDENT][/INDENT][/INDENT]&lt;BR /&gt;[INDENT][INDENT][INDENT][INDENT]cost = row[0][/INDENT][/INDENT][/INDENT][/INDENT]&lt;BR /&gt;[INDENT][INDENT][INDENT][INDENT]print cost[/INDENT][/INDENT][/INDENT][/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which prints to standard output:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;BestRoute\Routes&lt;BR /&gt;An error occurred on line XXX&lt;BR /&gt;cannot open 'BestRoute\Routes'&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So "BestRoute\Routes" is the long name of the Routes layer but (apparently) not the input that arcpy.da.SearchCursor expects. Generic layer properties (longName, isBroken...) can be accessed with my code, but not those network-related.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess I'm missing the mechanism to access the network properties of the sublayer Routes that is stored in the composite layer...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be much appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[NOTE: Mistakenly, I posted this question in the Beta Programs forum before. Apologies]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Jul 2013 15:37:03 GMT</pubDate>
    <dc:creator>FernandoSanchez2</dc:creator>
    <dc:date>2013-07-02T15:37:03Z</dc:date>
    <item>
      <title>How to access Route sublayer properties with ArcPy?</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/how-to-access-route-sublayer-properties-with-arcpy/m-p/456125#M4334</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;After solving a route I need to read the properties of the Route class. Concretely the Total_[Impedance] field as I want to compare different routes with regard to this attribute. Is there any way to do this with ArcPy? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My code until this step is typical:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Courier New;"&gt;route_lyr = arcpy.na.MakeRouteLayer(nwork,"BestRoute", "Length", output_path_shape="TRUE_LINES_WITH_MEASURES")&lt;BR /&gt;route_lyr = route_lyr.getOutput(0)&lt;BR /&gt;sub_layers = arcpy.na.GetNAClassNames(route_lyr)&lt;BR /&gt;arcpy.na.AddLocations("BestRoute",sub_layers["Stops"],"stops.shp")&lt;BR /&gt;arcpy.na.Solve(route_lyr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then I thought about the following to get the Total_Length value of the solve result:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Courier New;"&gt;for lyr in arcpy.mapping.ListLayers(route_lyr):&lt;BR /&gt;[INDENT]if lyr.name == "Routes":[/INDENT]&lt;BR /&gt;[INDENT][INDENT]print lyr.longName&amp;nbsp;&amp;nbsp; ### Printed just for demonstration purposes[/INDENT][/INDENT]&lt;BR /&gt;[INDENT][INDENT]with arcpy.da.SearchCursor(lyr.longName, ['Total_Length']) as cursor:&amp;nbsp; [/INDENT][/INDENT]&lt;BR /&gt;[INDENT][INDENT][INDENT][INDENT]### "BestRoute\Routes" is passed. [/INDENT]&lt;BR /&gt;[/INDENT][/INDENT][/INDENT]&lt;BR /&gt;[INDENT][INDENT][INDENT][INDENT]### The error is thrown here[/INDENT][/INDENT][/INDENT][/INDENT]&lt;BR /&gt;[INDENT][INDENT][INDENT]for row in cursor:[/INDENT][/INDENT][/INDENT]&lt;BR /&gt;[INDENT][INDENT][INDENT][INDENT]cost = row[0][/INDENT][/INDENT][/INDENT][/INDENT]&lt;BR /&gt;[INDENT][INDENT][INDENT][INDENT]print cost[/INDENT][/INDENT][/INDENT][/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which prints to standard output:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;BestRoute\Routes&lt;BR /&gt;An error occurred on line XXX&lt;BR /&gt;cannot open 'BestRoute\Routes'&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So "BestRoute\Routes" is the long name of the Routes layer but (apparently) not the input that arcpy.da.SearchCursor expects. Generic layer properties (longName, isBroken...) can be accessed with my code, but not those network-related.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess I'm missing the mechanism to access the network properties of the sublayer Routes that is stored in the composite layer...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be much appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[NOTE: Mistakenly, I posted this question in the Beta Programs forum before. Apologies]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 15:37:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/how-to-access-route-sublayer-properties-with-arcpy/m-p/456125#M4334</guid>
      <dc:creator>FernandoSanchez2</dc:creator>
      <dc:date>2013-07-02T15:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Route sublayer properties with ArcPy?</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/how-to-access-route-sublayer-properties-with-arcpy/m-p/456126#M4335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have tried and I haven't problem (see attach)[ATTACH=CONFIG]25663[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 17:59:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/how-to-access-route-sublayer-properties-with-arcpy/m-p/456126#M4335</guid>
      <dc:creator>nicogis</dc:creator>
      <dc:date>2013-07-02T17:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Route sublayer properties with ArcPy?</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/how-to-access-route-sublayer-properties-with-arcpy/m-p/456127#M4336</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you ciava.at. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I eventually came up with the following way (changes underlined):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Courier New;"&gt;for lyr in arcpy.mapping.ListLayers(route_lyr):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [INDENT]if lyr.name == "Routes":[/INDENT]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [INDENT][INDENT]with arcpy.da.SearchCursor(&lt;SPAN style="text-decoration:underline;"&gt;lyr&lt;/SPAN&gt;, ['Total_Length']) as cursor:[/INDENT][/INDENT]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [INDENT][INDENT][INDENT]for row in cursor:[/INDENT][/INDENT][/INDENT]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [INDENT][INDENT][INDENT][INDENT]print row[0][/INDENT][/INDENT][/INDENT][/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which way performs faster, I can't say.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Jul 2013 19:31:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/how-to-access-route-sublayer-properties-with-arcpy/m-p/456127#M4336</guid>
      <dc:creator>FernandoSanchez2</dc:creator>
      <dc:date>2013-07-04T19:31:36Z</dc:date>
    </item>
  </channel>
</rss>

