Select to view content in your preferred language

Using python to set time attribute parameters for NA VRP?

4304
2
Jump to solution
05-12-2015 07:04 AM
LauraBlackburn
Deactivated User

Hi All,

I have python code that runs the vehicle routing problem in Network Analyst.  I am using a Streets SDC-based network dataset to solve the VRP.  However, this dataset is uneditable.  I have run into issues with some road segments with speed limits under 20MPH and would like to change the time attribute associated with those roads.  I cannot edit the streets table and I cannot edit the network dataset's attributes.  So, I was hoping to be able to set the time attribute parameters in python.  However, I am not sure how to go about doing this.  Has anyone else done this?  If not, where do I find a streets network dataset that I can edit?

Any help is greatly appreciated!

0 Kudos
1 Solution

Accepted Solutions
MelindaMorang
Esri Regular Contributor

Hi Laura.

To change an attribute parameter on a network analysis layer in python, you can use the Update Analysis Layer Attribute Parameter tool: ArcGIS Help (10.2, 10.2.1, and 10.2.2)

Alternatively, if you want a little more flexibility, you can get the layer's solver properties and set the attribute parameters on the solver properties object.  Here are some relevant doc pages for this procedure (including code samples):

ArcGIS Help (10.2, 10.2.1, and 10.2.2)

ArcGIS Help (10.2, 10.2.1, and 10.2.2)

If this doesn't suit your needs and you want a new network dataset, there are a few options:

- Contact your city, county, regional, or state government GIS department to see if they have a network dataset for the region you are studying.  If they don't have a network dataset, they might have a streets layer you can use to create one.

- Download OpenStreetMap data for the area you are studying and create a network dataset from that.

- Download Tiger streets shapefiles from the US Census Bureau and create a network dataset from that.

- Purchase a Streetmap Premium network dataset covering your study area from one of the sources listed here: Product Matrix

View solution in original post

0 Kudos
2 Replies
MelindaMorang
Esri Regular Contributor

Hi Laura.

To change an attribute parameter on a network analysis layer in python, you can use the Update Analysis Layer Attribute Parameter tool: ArcGIS Help (10.2, 10.2.1, and 10.2.2)

Alternatively, if you want a little more flexibility, you can get the layer's solver properties and set the attribute parameters on the solver properties object.  Here are some relevant doc pages for this procedure (including code samples):

ArcGIS Help (10.2, 10.2.1, and 10.2.2)

ArcGIS Help (10.2, 10.2.1, and 10.2.2)

If this doesn't suit your needs and you want a new network dataset, there are a few options:

- Contact your city, county, regional, or state government GIS department to see if they have a network dataset for the region you are studying.  If they don't have a network dataset, they might have a streets layer you can use to create one.

- Download OpenStreetMap data for the area you are studying and create a network dataset from that.

- Download Tiger streets shapefiles from the US Census Bureau and create a network dataset from that.

- Purchase a Streetmap Premium network dataset covering your study area from one of the sources listed here: Product Matrix

0 Kudos
LauraBlackburn
Deactivated User

Thank you Melinda!  I was able to use the Update Analysis layer attribute parameter tool to change the time for the roads with speeds of less than 20 mph using the following lines of code.

    arcpy.na.UpdateAnalysisLayerAttributeParameter(outNALayer, "Time", "1MPH", 20)
    arcpy.na.UpdateAnalysisLayerAttributeParameter(outNALayer, "Time", "5MPH", 20)
    arcpy.na.UpdateAnalysisLayerAttributeParameter(outNALayer, "Time", "OtherRoads", 20)
0 Kudos