3

I have several points (bicycle share hubs), and I want to calculate the distance between each of them using a network. I want a CSV/XLS that has three headers: hub_id1, hub_id2, distance.

I've created a network dataset (after consultation), but how do I get the distance between each of the (blue) hubs pictured below?

I know a dollop of Python, so if this requires some scripting, I'm comfortable trying to apply what I know. I'll be the first to say, though, that I've not scripted with spatial data before.

FYI, both of these posts ask a similar question, but not using a network grid.

Would love some input! Thanks!

Bicycle hubs and the street grid in ArcGIS.

2

1 Answer 1

1

You can do this with pgRouting, using distance as cost function, without much programming. Using, for example, Dijkstra to compute the shortest distance between two nodes in the network (here 30 and 60):

SELECT SUM(cost) as distance FROM pgr_dijkstra(' SELECT gid AS id, source::integer, target::integer, length::double precision AS cost FROM ways', 30, 60, false, false);

With a bit of pgpsql you can iterate through the network and store these distances in a table.

Your Answer

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

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