--Create a dataset with nodes
insert into distance_nodes (name,node,edge,cost,geom) (
SELECT '1h_walk_vh',id1 AS node, id2 AS edge, cost, geom
FROM pgr_drivingdistance(
'SELECT id, source, target, walk_cost as cost FROM public.sweden_2po_4pgr',
732011, 1, false, false --from VH an one hour away
) as di
JOIN sweden_osm2po_nodes pt
ON di.id1 = pt.id
);
--Create a isocrone polygon
INSERT INTO distance_polygons (name,max_cost, geom) (
SELECT 'Ola',0.25, ST_ConvexHull(ST_SetSRID(ST_MakePolygon(ST_AddPoint(foo.openline, ST_StartPoint(foo.openline))),4326)) as geom
from
(
SELECT ST_MakeLine(points ORDER BY id) AS openline FROM
(
SELECT ST_MakePoint(x, y) AS points, row_number() over() AS id from
pgr_alphashape($$SELECT node as id, ST_X(geom) AS x, ST_Y(geom) AS y
FROM public.distance_nodes WHERE cost < 0.25 and name ='test'$$)
) as a
) as foo )
|