Select to view content in your preferred language

# calculating driving distances

24189
25
05-19-2011 10:21 AM
New Contributor
hello,

i am new to arcgis and am trying to calculate the driving distances between 2 sets of xy coordinates.

i have a data set with 5 columns--id, x-origin, y-origin, x-destination, y-destination--and would like to create a new showing the driving distance between the respective xy coordinates.

i was told that this might be possible using network analyst but have never worked with that tool.

any help would be appreciated!

Daniel
Tags (2)
25 Replies
New Contributor
If you only need to know the location and distance then use the OD Cost Matrix solver. But if you need the actual route to be shown then continue to use Closest Facility.

To solve your problem of finding ONE closest hospital, set a cutoff distance or time, say 60 miles or 60 minutes.
(i.e.. what ever is reasonable in your case).
Turn off hierarchy.
Set number of facilities to find as 1.
Solve.

it should work with 50,000 incidents and 10,000 facilities.
If it does not, can you report back to how far it gets or what error message is reported.

Also, If you are using these points over and over again, I will suggest that you run the GP tool, Calculate Locations on your hospitals and patients so that you can load them by network locations (not geometry) into a new network layer.

Jay Sandhu

Now I understand more about what you are talking. Really helpful! Thanks. I just hope it will work with more than million patients in one SOLVE.

Have a nice weekend!

Xiaomin
Esri Regular Contributor
I think it may not work with one million patients. I will suggest that you split it into 10 solves of 100,000 patients each, write out the results and combine them at the end.

Couple of other things you can do is to run ArcGIS on a windows 64 bit machine with 4 GB RAM. On a 32 bit OS, the maximum memory it can use is 2 GB but on a 64 bit OS it can use 4 GB.

If you have multiple cores, like a quad core machine, you can use the GP background processing to run more than one solve simultaneously to speed it up. For example, run two solves of 100,000 each.

Jay Sandhu
New Contributor
If I understand your objective correctly, you want to find the driving distance from one specific origin to one specific destination, not from all origins to all destinations. This is important because, at first glance, you might think the OD cost matrix solver would work best, but actually it's probably best to do the following using a route layer instead:

1. On your dataset, create a new field named RouteName and calculate its value so that it is the same value as your current ID field.
2. Add your origins to ArcMap as a layer. (Tip: File > Add Data > Add XY Data.) Only specify the origin X and Y fields.
3. Rename the output layer that appears in the table of contents to something like Origins.
4. Add your destinations to ArcMap as a layer. Only specify the destination X and Y fields.
5. Rename the output layer to Destinations.
6. Make a Route layer using the Network Analyst toolbar (or a GP tool).
7. Load the Origins layer into the Stops class. (Tip: Right-click Stops in the Network Analyst window and choose Load Locations.) Make sure the RouteName field is mapped to the RouteName field you created.
8. Load the Destinations layer into the Stops class using the same method.
9. Solve

By specifying the route name when loading, the stops are grouped together and routes are calculated only for the stops that are in the same group, which in your case is limited to a single origin and destination pair.

You can open, and optionally export, the Routes class, which contains the calculated shortest-path driving distances. The Name field values will match the values of your original IDs.

Hi, thank you Robert Garrity and Jay Sandhu for step-by-step guidance to this query. I followed it, but for some reason only some of the O-D pairs are solved. My data set has more than 35,000 trips, or pairs or OD points, but only 5700 were solved. I get two kinds of error warnings, the samples are below:
1. Warning: Location "Location 11" in "Stops" is on a non-traversable network element position.
2. Warning: No route for "9901" from location "Location 9902" to location "Location 47260"

What is want to do is find the shortest route between each pair of O-D points on each of these trips. The data has been obtained from a travel survey using GPS that gives X,Y coordinates for each origin and each destination for each trip.

I think in my case, all the street center-lines have been identified as edges, however, all OD points not falling directly on the edges are showing up as errors and not able to snap to closest edge/street.

Any help will be appreciated! I am new to Network Analysis and this forms a critical part of my doctoral thesis!

Thanks, Sweta
Esri Regular Contributor
>1. Warning: Location "Location 11" in "Stops" is on a non-traversable network element position.

This means that your location is located on an edge which is restrictred due to some restriction like oneway. So check the properties of your route layer and see what restrictions are on. Can some of them be turned off? If not, then on the network locations tab of your route layer, at the bottom, there is a property called "Exclude restricted portions of the network". Check on this property. Now you will have to "re-locate" your stops. So in the NAWindow, right-click on the Stops and choose Re-calculate Location Fields and choose All (or select only the problem stops before and relocate only the selected ones).

>2. Warning: No route for "9901" from location "Location 9902" to location "Location 47260"

This is becase there is no path between these two locations. Most likely this could be due to restrictions that are on in the data or there is disconnected pieces in the network. So you will have to investigate that be turning off ALL restrictions and seeing if you can find a path or not.

>I am new to Network Analysis and this forms a critical part of my doctoral thesis!

Just an observation: If you choose to use a tool that is critical to the thesis then you need to be a master at it before you make it a critical part....but it is probably too late for that now.

Jay Sandhu
New Contributor
Thanks Jay Sandhu, yes that solved the problem! Most of the errors related to "one-way" restrictions on the Route Layer which was easily corrected. However, I had a tough time trying to save results and had to repeat the procedure several times before I could manage to do it. The file size increased from 180MB to about 550MB. I have about 70,000 stops, and more than 30,000 routes. Is that normal?

I agree, ideally I should have mastered this extension before I made this an important part of my dissertation. Its an important, but small part.... hoping to learn along the way, and these ArcGIS forums are very useful! Thanks again for the help!

Regards, Sweta
Esri Regular Contributor
Glad to know you have it working. As far as file size, it may depend on how many route layers you have in ArcMap. Each will require it's own memory for that many stops/routes. One thing you can do is instead of Save, do a Save As to a new file name and that will most likley be smaller as it will get rid of any unnecessary information being stored in that map document.

As far as "observation" it was more of a helpful suggestion that when it comes to defending your thesis, you do not want to admit ignorance about any aspect of your work!

Jay Sandhu, Ph.D. 🙂
New Contributor II
Hi Jay,

I also have an extremely large MXD (1.6GB!) that I'm trying to work with.  I've got routes worked out for 80 facilities and 76,000 incidents over a national network dataset using the closest facilty geoprocess.  Just wondering if you've established some form of 'best practices' for working with rather large MXDs?  Your help would be much appreciated.  Arc 10, SP3, XP.

Matt
Esri Regular Contributor
If you solve a large closest facility problem in ArcMap and then write it out as an MXD it will take a lot of space. Is there a reason you need to save this in a map document? Can you export out the lines layer to a feature class (shape file or geodatabase) and then add it to the ArcMap TOC and save that map document? that way the data is not saved in the map document. You could also export the entire CF layer to disk to save a copy as well.

Jay Sandhu
New Contributor
If I understand your objective correctly, you want to find the driving distance from one specific origin to one specific destination, not from all origins to all destinations. This is important because, at first glance, you might think the OD cost matrix solver would work best, but actually it's probably best to do the following using a route layer instead:

1. On your dataset, create a new field named RouteName and calculate its value so that it is the same value as your current ID field.
2. Add your origins to ArcMap as a layer. (Tip: File > Add Data > Add XY Data.) Only specify the origin X and Y fields.
3. Rename the output layer that appears in the table of contents to something like Origins.
4. Add your destinations to ArcMap as a layer. Only specify the destination X and Y fields.
5. Rename the output layer to Destinations.
6. Make a Route layer using the Network Analyst toolbar (or a GP tool).
7. Load the Origins layer into the Stops class. (Tip: Right-click Stops in the Network Analyst window and choose Load Locations.) Make sure the RouteName field is mapped to the RouteName field you created.
8. Load the Destinations layer into the Stops class using the same method.
9. Solve

By specifying the route name when loading, the stops are grouped together and routes are calculated only for the stops that are in the same group, which in your case is limited to a single origin and destination pair.

You can open, and optionally export, the Routes class, which contains the calculated shortest-path driving distances. The Name field values will match the values of your original IDs.

I'm having problems with this.  I'm able to load the origins and destinations into the Stops and assign the Route Name for each.  My stops then show up paired by the Route Name values, which seems correct - I want to know the driving distances for paths between specific pairs of points. When I solve, the solve fails and give the errors "Warning: Location "Location 1" in "Stops" is unlocated." for a lot of locations.  These are locations of where women live and the mammography screening facility they attended.  I don't have the facility for some women, so I figured those would be unsolved, but it doesn't solve any routes for those that have both locations.  When I loaded origins and destinations into OD Cost Matrix, it solved everything, but was obviously more than I wanted since it did all routes, not the specific route per woman.  Any suggestions are appreciated!
Esri Contributor
Hi Jenna,

When you load the stops, are you loading using geometry or network location fields? (This option is at the bottom of the Load Locations dialog box.) If so, what is the Search Tolerance you are using?

Also, zoom into an unlocated stop and use the Measure tool on the Tools toolbar to see how far the stop is from the nearest street. What's the distance? If you're using geometry to load locations and the point is farther than the search tolerance, the stop won't locate.

The default search tolerance is 5000 meters, so if you're using the default, it's unlikely the stops are not going to be located. But it's a good place to start looking.

If you're using network location fields to load, were the network location fields calculated using the same network dataset you're using to create the route layer?

Robert