1

I have two layers, one with lines and the other with points. Layer one has all the points (A to J) as shown below and layer two has all the lines connecting these points. Is there an automated way (in ArcGIS or shapely or anything) to calculate the distance between every pair of points where my definition of distance is the actual length of the connecting lines?

Please note that I am not looking for line-of-sight distance between points which can be computed using Haversine or Vincenty.

enter image description here

2 Answers 2

2

Yes, but you must have network analyst. You would first create a network dataset out of your line features (http://help.arcgis.com/EN/arcgisdesktop/10.0/help/index.html#//00470000005t000000)

Then you would use the network analyst to solve the closest facility problem. Your facility will be the your starting point (or the point you want to measure from). For your incidents you can load your file containing all the other points you want to measure to. In the accumulation tab under properties of the closest facility in the TOC you can set your accumulation to feet or miles or whatever you want distance in. Then solve the network problem and Then right click on routes in the TOC and you will see a table called Total_Length or Total_Cost or something similar, that will be your distance along your network from one point to the endpoint along the network route. You will have to do this for each point you want to measure from.

Here is a great tutorial on how to do this.

http://help.arcgis.com/en/arcgisdesktop/10.0/pdf/network-analyst-tutorial.pdf

2
  • 1
    @drk Note that if you don't need the routes, just the lengths, the OD Cost Matrix solver is the tool designed to do this though it does have some potential quirks/errors depending on the data. You can also use the CF solver as this answer suggests to get all the points at once. You just need to add all points as both incidents and facilities, and set the solver to find the nearest x facilities where x is the number of points you have.
    – Chris W
    Sep 23, 2015 at 17:47
  • Ah I did not know you could add them all as both facilities and points, I have always done them one at a time. Very good to know!
    – ed.hank
    Sep 23, 2015 at 17:50
2

The short answer is 'yes' there are automated ways of doing this. In ArcGIS you want the Network Analyst module, which you may not have access to. It you do not, then there are OpenSource alternatives such as using PostGIS and PgRouting (note there's a few alternative algorithms offered for all-pairs calculations).

QGIS has a Road Graph plugin, but I don't think this will do all your pairs in one step. You would have to manually tell it to run the calculation pair-by-pair, possibly with a little batch script.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.