Select to view content in your preferred language

Creating new impedance for Service Area Analysis in ArcPy

829
3
08-29-2023 03:11 PM
JonathanSpenceUofA
Emerging Contributor

I'm currently working on a service area problem in ArcPy and have run into an issue.

As opposed to using a standard impedance/cost for the service area, I want the impedance to be calculated based on a field I calculated for each segment of the network.

More specifically, I took two feature classes (one for roadways, and one for railways), and calculated the monetary cost of moving across each segment (distance * a given cost per distance). I then combined the two feature classes to create a new feature class with each segment having its own unique transport cost associated with it that was then used in my network dataset and service area. 

This all worked out fine, but I just need to know how I can chose the impedance to be calculated based on that field in ArcPy for the service area layer I created in ArcPy.

Please let me know how I can do this,

Thanks

0 Kudos
3 Replies
MelindaMorang
Esri Regular Contributor

Hi Jonathan.  Happy to help.

I couldn't tell from your question whether you have already created a cost attribute in your network based on the field you calculated.  If not, the first thing you need to do is set up this cost attribute: https://pro.arcgis.com/en/pro-app/latest/help/analysis/networks/cost-attributes.htm  You can't do that via Python.  It should be done manually as an edit to the network dataset properties, and once you've set it up, you have to run the Build Network tool to build the network and incorporate those changes.

You should probably also configure a travel mode on the network that uses the new cost attribute and any restrictions you want to apply during the analysis: https://pro.arcgis.com/en/pro-app/latest/help/analysis/networks/travel-modes.htm

Once your network is configured correctly, you can use the travel mode when configuring your analysis in arcpy.

I noticed that you mentioned using a service area layer in arcpy.  This is okay and will work, but we recommend using the newer/faster/simpler arcpy.nax module for doing network analysis in Python.  It doesn't use layers but instead uses a set of Python classes that should have everything you need. https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/performing-network-analysis.htm

0 Kudos
JonathanSpenceUofA
Emerging Contributor

Hi Melinda,

Thank you for this info! It's too bad that it can't be done in ArcPy. Any ideas if/when that issue will be fixed such that the whole SA process can be done in ArcPy?

0 Kudos
MelindaMorang
Esri Regular Contributor

We don't currently have any plans to allow full configuration of network dataset properties via Python.

Can you describe your workflow or end goal in more detail so I can better understand what you want to do?

Typically users create their network dataset once (manually) and then just use it in an automated script without the need to edit it.  Or, if you need to create multiple networks with the same schema, you can configure one once (manually) and run the Create Template From Network Dataset tool and then have your automated process use the Create Network Dataset From Template tool.

0 Kudos