# Calculate catchment area with pgrouting

I have the road networks from osm and I created topology.

I know that dijkstra algorithm works, because I calculated the shortest path from two point layers. Now I would like to calculate catchment area for my points (from first layer).

I checked, how works pgr_drivingDistance. The result is far from expected.

I tried these codes:

``````SELECT pgr_drivingDistance( 'select id, source, target, leng as cost from osm_roads'
, 221, 1000)
``````

where 221 is number of nodes. This code executed for a very long time and I had to stop it.

``````CREATE TABLE distances AS (SELECT a.node AS id, a.agg_cost AS distance, b.the_geom
FROM pgr_drivingDistance(
'SELECT gid AS id, source, target, leng as cost FROM public.osm_roads',
221,
1000
) a, osm_roads_vertices_pgr b WHERE a.node = b.id);
``````

but in this case result had only one point (start point) and this is not true.

I attach two screenshots: The second from visualization in QGIS. What am I doing wrong? Do you have an idea, how can I iprove my code?

I'm using PostgreSQL 10 with PostGIS 2.5.2 and Pgrouting 2.6.2.

• your first query executes `pgr_drivingDistance` once for every row in `osm_roads_vertices_pgr`; it simply fetches the full table, but instead of selecting columns that function will be executed for each row. just omit the `FROM osm_roads_vertices_pgr`. as to your actual issue; without knowing your network, this is impossible to debug (it might just as well be the expected result, and it just needs an explanation as to why it is) Oct 23, 2019 at 13:30
• I have just added two screenshots. Oct 23, 2019 at 13:54
• what's the unit of `leng`, meter? What happens if you replace it with `ST_Length(geom::GEOGRAPHY) AS cost`? Oct 23, 2019 at 15:15
• I have this message: "Only lon/lat coordinate systems are supported in geography." When I delete ":GEOGRAPHY", result is the same. Unit of leng is meter. Coordinates are also in meters (EPSG:2180). Oct 24, 2019 at 18:06