How to access Network Analyst output sublayers using python

543
1
11-09-2011 11:30 AM
MelindaMorang1
New Contributor III
I'm trying to figure out how to grab and manipulate Network Analyst output sublayers using python.

For instance, I've successfully run an OD cost matrix calculation using python geoprocessing. I get the "Lines" output sublayer. This is probably just a stupid problem, but I can't seem to figure out how to work with the Lines sublayer (or just what the syntax should be to refer to it) in python after I create it.

I want to:
- Create fields in the Lines layer corresponding to my unique stop ids that I put in the origin and destination sublayers and then join the Lines layer to the origin and destination layers so I can grab the stop ids.
- Export the Lines layer attributes table, including the new fields with the stop id, to a csv

I can do all this by hand, but I want to do it in python, and I'm really stuck.

Thanks.
Tags (2)
0 Kudos
1 Reply
StacyRendall1
Occasional Contributor III
If the layer name that you are after is lines, you should be able to just get it with networkAnalystLayerName+'\\Lines' (where networkAnalystLayerName is the name of the layer you are doing the network analyst stuff on) , i.e.:
# if NA_Layer is the variable for your network analyst layer
arcpy.Solve_na(NA_Layer)
lines = NA_Layer + '\\Lines'


Then you will probably need to copy features (i.e. arcpy.CopyFeatures_management(lines)) and do your modifications on the output of copy features.
0 Kudos