[GIS] How to create isochrones in postgis/osm2po/pgrouting and then save the isochrones as polygons

isochroneosm2popgroutingpolygon-creationpostgis

I am creating some isochrones in pgrouting based upon a table from osm2po. Now I have a query that will get all of the edges that are c driving distance away from a point. How can I save this query or these individual isochrones into a table of polygons?

Perhaps a little background might help: I want to show how the isochrones change over time as different events occur or as event intensities change. So I wanted to be able to create a video that shows how the contours of the isochrones changes over time. Hence I need to create a table that has each isochrone polygon, as well as a timestamp for the date.

Any help you can provide in converting the isochrones into polygons — hopefully in PostGIS — is welcome.

Best Answer

Just join the geometry column from the original edge table which holds the geometry column. Your query will look like this:

SELECT t1.seq, t1.id1 AS Node, t1.id2 AS Edge, t1.cost, t2.geometry FROM PGR_DrivingDistance(
  'SELECT id, source, target, cost FROM edge_table',
  1, 10, false, false) t1, edge_table t2
WHERE t1.id2 = t2.edge_id

If you want the Nodes instead of the Edges then just refer to the vertex table's geometry column like this:

SELECT t1.seq, t1.id1 AS Node, t1.id2 AS Edge, t1.cost, t2.geometry FROM PGR_DrivingDistance(
  'SELECT id, source, target, cost FROM edge_table',
  1, 10, false, false) t1, edge_vertex_table t2
WHERE t1.id2 = t2.vertex_id