Database Reference
In-Depth Information
Driving
distance/service
area
calculation
Drivingdistance(
pgr_drivingDistance
)isaquerythatcalculatesallnodeswithin
thespecifieddrivingdistanceofastartingnode.Thisisanoptionalfeaturecompiled
with pgRouting; so if you compile pgRouting yourself, make sure that you enable it
and include the CGAL library, a required dependency for
pgr_drivingDistance
.
Drivingdistanceisusefulwhen"usersheds"areneededthatgiverealisticdrivingdis-
tance estimates, for example, for all customers within 5 miles of driving, biking, or
walkingdistance.Theseestimatescanbecontrastedwithbufferingtechniques,which
assumenobarriertotravellingandareusefulforrevealingtheunderlyingstructures
of our transportation networks relative to individual locations.
Getting ready
We will load the same dataset that we used in the
Startup - Dijkstra routing
recipe.
Refer to this recipe to import data.
How to do it...
Inthefollowingexample,wewilllookatalluserswithinthedistanceof1.5unitsfrom
our starting point, thatis, a proposed bike shop at node 7:
SELECT seq, id1 AS node, cost
FROM pgr_drivingDistance(
'SELECT id, source, target, cost FROM
edge_table',
67, 1.5, false, false
);
The preceding command gives the following output:
seq | node | cost
-----+------+------