<?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 the Route sublayer properties in arcpy in ArcGIS Network Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-network-analyst-questions/how-to-access-the-route-sublayer-properties-in/m-p/91814#M924</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;&lt;BR /&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;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&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;SPAN style="font-family:Courier New;"&gt;&lt;BR /&gt;for lyr in arcpy.mapping.ListLayers(route_lyr):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [INDENT]if lyr.name == "Routes":&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [INDENT]print lyr.longName&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;&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; # Printed just for explanatory purposes&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sCursor = arcpy.SearchCursor(lyr.longName)&amp;nbsp;&amp;nbsp; # "BestRoute\Routes" is passed. The error is thrown here&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while sCursor:&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]row = sCursor.next()&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; cost = row.getValue("Total_Length")&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; print cost[/INDENT]&lt;BR /&gt;[/INDENT]&lt;BR /&gt;[/INDENT]&lt;BR /&gt;&lt;/SPAN&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;SPAN&gt; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BestRoute\Routes&lt;BR /&gt; An error occurred on line XXX&lt;BR /&gt; "BestRoute\Routes" does not exist&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&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 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;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 30 Jun 2013 19:50:40 GMT</pubDate>
    <dc:creator>FernandoSanchez2</dc:creator>
    <dc:date>2013-06-30T19:50:40Z</dc:date>
    <item>
      <title>How to access the Route sublayer properties in arcpy</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/how-to-access-the-route-sublayer-properties-in/m-p/91814#M924</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;&lt;BR /&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;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&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;SPAN style="font-family:Courier New;"&gt;&lt;BR /&gt;for lyr in arcpy.mapping.ListLayers(route_lyr):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [INDENT]if lyr.name == "Routes":&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [INDENT]print lyr.longName&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;&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; # Printed just for explanatory purposes&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sCursor = arcpy.SearchCursor(lyr.longName)&amp;nbsp;&amp;nbsp; # "BestRoute\Routes" is passed. The error is thrown here&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while sCursor:&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]row = sCursor.next()&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; cost = row.getValue("Total_Length")&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; print cost[/INDENT]&lt;BR /&gt;[/INDENT]&lt;BR /&gt;[/INDENT]&lt;BR /&gt;&lt;/SPAN&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;SPAN&gt; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BestRoute\Routes&lt;BR /&gt; An error occurred on line XXX&lt;BR /&gt; "BestRoute\Routes" does not exist&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&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 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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Jun 2013 19:50:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/how-to-access-the-route-sublayer-properties-in/m-p/91814#M924</guid>
      <dc:creator>FernandoSanchez2</dc:creator>
      <dc:date>2013-06-30T19:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to access the Route sublayer properties in arcpy</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/how-to-access-the-route-sublayer-properties-in/m-p/91815#M925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I just realized I posted this in the wrong Forum. Apologies for that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 15:13:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/how-to-access-the-route-sublayer-properties-in/m-p/91815#M925</guid>
      <dc:creator>FernandoSanchez2</dc:creator>
      <dc:date>2013-07-02T15:13:03Z</dc:date>
    </item>
  </channel>
</rss>

