Select to view content in your preferred language

Input location using to Network Analyst and Finding the route

634
3
Jump to solution
04-09-2018 02:40 AM
JohnMcConalogue
Occasional Contributor

I have a shapefile of locations and have another shapefile with one location which is a Start Point.

I want to input the name of one of the locations and then Network Analyst will return the best route to the location from the Start Point.

Anyone know how this can be achieved using python?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RachelApplebaum
Esri Contributor

You'll need to geocode the address to get the location in a feature layer/table (which can be in memory) then pass that feature layer/table into Add Locations (Add Locations—Help | ArcGIS Desktop ).

Of course for the geocoding, you'll need a geocoder or a geocoding service. If you have your own, you can use that, or you could also use Google or several other options. See the options in Geocode only one address in arcpy.  or Geocode Addresses—Help | ArcGIS Desktop or arcgis desktop - How to geocode a single address in Python Script/ ModelBuilder? - Geographic Inform...  for ideas.

View solution in original post

0 Kudos
3 Replies
NeilAyres
MVP Alum

Doing this in python is actually quite complicated (imho).

Some tips here, see example 4

Make Route Layer—Help | ArcGIS Desktop 

JohnMcConalogue
Occasional Contributor

Thanks for the reply Neil.

I am trying to get the user to add the address and then Network analyst will fine the route.

Here is the code prompting the user to input the address:

if len(address) == 0: address = raw_input("Which address do you wish to examine? ") QueryString = "Address_Name = \'" + address.title() + "\'"

Any idea how to pass the "address" parameter to the python script to be used by Network analyst?

0 Kudos
RachelApplebaum
Esri Contributor

You'll need to geocode the address to get the location in a feature layer/table (which can be in memory) then pass that feature layer/table into Add Locations (Add Locations—Help | ArcGIS Desktop ).

Of course for the geocoding, you'll need a geocoder or a geocoding service. If you have your own, you can use that, or you could also use Google or several other options. See the options in Geocode only one address in arcpy.  or Geocode Addresses—Help | ArcGIS Desktop or arcgis desktop - How to geocode a single address in Python Script/ ModelBuilder? - Geographic Inform...  for ideas.

0 Kudos