How to access the Route sublayer properties in arcpy

1907
1
06-30-2013 12:50 PM
FernandoSanchez2
New Contributor
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?

My code until this step is typical:


route_lyr = arcpy.na.MakeRouteLayer(nwork,"BestRoute", "Length", output_path_shape="TRUE_LINES_WITH_MEASURES")
route_lyr = route_lyr.getOutput(0)
sub_layers = arcpy.na.GetNAClassNames(route_lyr)
arcpy.na.AddLocations("BestRoute",sub_layers["Stops"],"stops.shp")
arcpy.na.Solve(route_lyr)
 

Then I thought about the following to get the Total_Length value of the solve result:


for lyr in arcpy.mapping.ListLayers(route_lyr):
    [INDENT]if lyr.name == "Routes":
        [INDENT]print lyr.longName                                      # Printed just for explanatory purposes
        sCursor = arcpy.SearchCursor(lyr.longName)   # "BestRoute\Routes" is passed. The error is thrown here
        while sCursor:
            [INDENT]row = sCursor.next()
            cost = row.getValue("Total_Length")
            print cost[/INDENT]
[/INDENT]
[/INDENT]


Which prints to standard output:


        BestRoute\Routes
An error occurred on line XXX
"BestRoute\Routes" does not exist
       


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.

I guess I'm missing the mechanism to access the network properties of the sublayer Routes that is stored in the composite layer...

Any help would be much appreciated.
Tags (2)
0 Kudos
1 Reply
FernandoSanchez2
New Contributor
I just realized I posted this in the wrong Forum. Apologies for that.
0 Kudos