Site analyses can benefit greatly from using “drive-time” isochrones to define the study area. Drive time isochrones are often significantly different from simple buffer areas which disregard natural barriers such as rivers or slow roads.
Of course, creating drive time isochrones requires more input data and more compute-intensive algorithms than a simple buffer analysis. It is necessary to create a routable network graph with adequate weights to be used by the routing algorithm.
One of the most popular routing applications in the open source world is pgRouting for PostGIS enabled databases. I’ve already shown how to create drive time isochrones for one network node based on pgRouting and QGIS. Today, I’ll show how to create drive time isochrones for a set of points – in this case all airports in Finland.
The first step is to find the closest network node to every airport:
ALTER TABLE airport ADD COLUMN nearest_node integer; CREATE TABLE temp AS SELECT a.gid, b.id, min(a.dist) FROM (SELECT airport.gid, min(distance(airport.the_geom, node.the_geom)) AS dist FROM airport, node GROUP BY airport.gid) AS a, (SELECT airport.gid, node.id, distance(airport.the_geom, node.the_geom) AS dist FROM airport, node) AS b WHERE a.dist = b. dist AND a.gid = b.gid GROUP BY a.gid, b.id; UPDATE airport SET nearest_node = (SELECT id FROM temp WHERE temp.gid = airport.gid);
Then, we can calculate drive times between network nodes and “airport nodes”. I am still looking for the most efficient way to perform this calculation. The trivial solution I used for this example was to calculate all drive time values separately for each airport node (as described in “Creating Catchment Areas with pgRouting and QGIS”).
I create the table with the first node:
CREATE TABLE catchment_airport AS SELECT id, the_geom, (SELECT sum(cost) FROM ( SELECT * FROM shortest_path(' SELECT gid AS id, start_id::int4 AS source, end_id::int4 AS target, traveltime::float8 AS cost FROM network', 5657, id, false, false)) AS foo ) AS cost FROM node;
Every following node is done with an INSERT:
INSERT INTO catchment_airport ( SELECT id, the_geom, (SELECT sum(cost) FROM ( SELECT * FROM shortest_path(' SELECT gid AS id, start_id::int4 AS source, end_id::int4 AS target, traveltime::float8 AS cost FROM network', 123, -- put a new index here! id, false, false)) AS foo ) AS cost FROM node);
Afterwards, I combined the values to find the minimum drive time for each network node:
CREATE table catchment_airport_final AS SELECT id, the_geom, min (cost) AS cost FROM catchment_airport GROUP By id, the_geom;
The resulting point layer was imported into QGIS. Using TIN interpolation (from Interpolation plugin), you can calculate a continuous cost surface. And Contour function (from GDALTools) finally yields drive time isochrones.
Based on this analysis, it is possible to determine how many inhabitants live within one hour driving distance from an airport or how many people have to drive longer than e.g. ninety minutes to reach any airport.