You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Documentation instructions for routing no longer work (pgrouting >=4) #408
What operating system, osm2pgsql, and PostgreSQL/PostGIS versions are you using?
Using Docker
What did you do exactly?
I was following the instructions for setting up routing here: https://pgosm-flex.com/routing.html and ran into the problem that all of the functions have been removed in version 4.0.0.
What did you expect to happen?
I expected the demo to work correctly.
What did happen instead?
Please see the error below:
pgosm=# SELECT pgr_nodeNetwork('routing.road_line', 0.1, 'id', 'geom');
SELECT pgr_createTopology('routing.road_line_noded', 0.1, 'geom');
SELECT pgr_analyzeGraph('routing.road_line_noded', 0.1, 'geom');
ERROR: function pgr_nodenetwork(unknown, numeric, unknown, unknown) does not exist
LINE 1: SELECT pgr_nodeNetwork('routing.road_line', 0.1, 'id', 'geom...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
ERROR: function pgr_createtopology(unknown, numeric, unknown) does not exist
LINE 1: SELECT pgr_createTopology('routing.road_line_noded', 0.1, 'g...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
ERROR: function pgr_analyzegraph(unknown, numeric, unknown) does not exist
LINE 1: SELECT pgr_analyzeGraph('routing.road_line_noded', 0.1, 'geo...
^
What did you do to try analyzing the problem?
I read the release notes and documentation of pgrouting. It looks like the workaround is a bit cumbersome, so I think the solution for me is to just downgrade to a version pgsom-flex that uses a version of pgrouting <4.
Do you have any plans to update the docs to work with the latest pgrouting version?
changed the title [-]Documentation instructions for pgrouting no longer work[/-][+]Documentation instructions for pgrouting no longer work (pgrouting >=4)[/+]on Dec 7, 2025
changed the title [-]Documentation instructions for pgrouting no longer work (pgrouting >=4)[/-][+]Documentation instructions for routing no longer work (pgrouting >=4)[/+]on Dec 7, 2025
Thanks for the heads up, @travishathaway! I'll start playing around with it. I hadn't realized I accidentally bundled a big upgrade on the pgrouting side. It's worth updating docs to keep up with the times.
If you have a chance to test and verify if this works for you that'd be fantastic. I'll do more thorough testing soon. I am pondering of a few new examples to add too.
I had the chance to try this out. I first attempted the Brandenburg dataset. I waited about 24 hours until I canceled it. After that I, I tried just Berlin and gave up after about 8 hours. So, I was unfortunately unable to finish.
This all got me thinking that it might be nice to have tips on how to reduce the graph size in the documentation. For example, I'm only interested in pedestrian routes, so maybe I just need to limit my network even further? I'll keep poking around at this and re-read your documentation to see if there's anything obvious about this in there I missed.
Based on what I come up with, I would be happy to submit a pull request to add more to the documentation with any tips or tricks that I discover.
An observation - pgr_separateTouching() takes a LOT longer to get the job done compared to the legacy pgr_nodeNetwork() function. Scaling from D.C. road network to Colorado road network goes from ~1 hour to ??? hours (21 hours and counting).
Using dryrun shows the CTE query it's running, so I'm digging into that direction. I hadn't looked too closely at the legacy function, so might do some comparison to see what changed.
SELECT*FROM pgr_separateTouching('SELECT id, geom FROM routing.osm_road_intermediate', dryrun => true)
;
This portion seems likely to be the bottleneck.
get_touching AS (
SELECTe1.id id1, e2.id id2, ST_Snap(e1.geom, e2.geom, 0.01) AS geom, e1.geomAS g1, e2.geomAS g2
FROM edges_table e1, edges_table e2
WHEREe1.id!=e2.idAND ST_DWithin(e1.geom, e2.geom, 0.01) AND NOT(
ST_StartPoint(e1.geom) = ST_StartPoint(e2.geom) OR ST_StartPoint(e1.geom) = ST_EndPoint(e2.geom)
OR ST_EndPoint(e1.geom) = ST_StartPoint(e2.geom) OR ST_EndPoint(e1.geom) = ST_EndPoint(e2.geom))
),
I had the chance to try this out. I first attempted the Brandenburg dataset. I waited about 24 hours until I canceled it. After that I, I tried just Berlin and gave up after about 8 hours. So, I was unfortunately unable to finish.
This all got me thinking that it might be nice to have tips on how to reduce the graph size in the documentation. For example, I'm only interested in pedestrian routes, so maybe I just need to limit my network even further? I'll keep poking around at this and re-read your documentation to see if there's anything obvious about this in there I missed.
Based on what I come up with, I would be happy to submit a pull request to add more to the documentation with any tips or tricks that I discover.
@travishathaway Yeah, performance has unfortunately tanked in the step to create the noded network using these new functions. I'll keep digging into that side of things, per my other comment it's unusable for the region I want too, and I don't want it limited!
For pedestrian routes you can adjust your input query with filters on the boolean columns, e.g. route_foot. I'd do that in the first routing.osm_road_intermediate step and it should cascade through the process from there. Note that the route_foot logic includes a variety of motorized roads in it's access controls. Depending on your area and how much dedicated footway infrastructure you have, you might want to include AND NOT route_motor, or be more specific with specific osm_type filters.
CREATETABLErouting.osm_road_intermediate AS
WITH a AS (
-- Remove as many multi-linestrings as possible with ST_LineMerge() SELECT osm_id, osm_type, maxspeed, oneway, layer,
route_foot, route_cycle, route_motor, access,
ST_LineMerge(geom) AS geom
FROMosm.road_lineWHERE route_foot --<---------------------Add this filter to limit to lines that are foot-routable
), extra_cleanup AS (
-- Pull out those that are still multi, use ST_Dump() to pull out partsSELECT osm_id, osm_type, maxspeed, oneway, layer,
route_foot, route_cycle, route_motor, access,
(ST_Dump(geom)).geom AS geom
FROM a
WHERE ST_GeometryType(geom) ='ST_MultiLineString'
), combined AS (
-- Combine two sourcesSELECT osm_id, osm_type, maxspeed, oneway, layer,
route_foot, route_cycle, route_motor, access,
geom
FROM a
WHERE ST_GeometryType(geom) !='ST_MultiLineString'UNIONSELECT osm_id, osm_type, maxspeed, oneway, layer,
route_foot, route_cycle, route_motor, access,
geom
FROM extra_cleanup
-- Some data may be lost here if multi-linestring somehow-- persists through the extra_cleanup queryWHERE ST_GeometryType(geom) !='ST_MultiLineString'
)
-- Calculate a new surrogate ID for keySELECT ROW_NUMBER() OVER (ORDER BY geom) AS id, *FROM combined
ORDER BY geom
;
@travishathaway Here's what I'm doing for testing with a tiny dataset, limiting the roads to a single neighborhood. I add a join to the first query in the CTE to return under 200 road segments but still with a routeable data set..
SELECTr.osm_id, r.osm_type, r.maxspeed, r.oneway, r.layer,
r.route_foot, r.route_cycle, r.route_motor, r.access,
ST_LineMerge(r.geom) AS geom
FROMosm.road_line r
INNER JOINosm.place_polygon p
ONp.osm_id=-4633701AND ST_intersects(r.geom, p.geom)
Sorry for all the noise -- but good news! I got the D.C. query down from 45 minutes to under 2 seconds. I'm going to try running this on the Colorado data, if it scales up well I'll publish a better version of the docs.
This query is the slow step from the pgr function, note all the ST_StartPoint()/ST_EndPoint() in the OR clause. No wonder this doesn't perform well.
CREATE TEMP TABLE get_touching AS
SELECT e1.id id1, e2.id id2, ST_Snap(e1.geom, e2.geom, 0.01) AS geom, e1.geom AS g1, e2.geom AS g2
FROM edges_table e1, edges_table e2
WHERE e1.id != e2.id AND ST_DWithin(e1.geom, e2.geom, 0.01) AND NOT(
ST_StartPoint(e1.geom) = ST_StartPoint(e2.geom) OR ST_StartPoint(e1.geom) = ST_EndPoint(e2.geom)
OR ST_EndPoint(e1.geom) = ST_StartPoint(e2.geom) OR ST_EndPoint(e1.geom) = ST_EndPoint(e2.geom))
;
SELECT 73258
Time: 2685600.856 ms (44:45.601)
This version doesn't show the changes that happened upstream, but the geom_start and geom_end columns are indexed geometries instead of on-the-fly calculations.
CREATE TEMP TABLE get_touching_new AS
SELECT e1.id AS id1, e2.id AS id2
, ST_Snap(e1.geom, e2.geom, 0.01) AS geom
, e1.geom AS g1
, e2.geom AS g2
FROM routing.osm_road_intermediate e1
, routing.osm_road_intermediate e2
WHERE
-- we could use < Instead of != to only report intersections.
-- The != results in two rows, e.g. 1, 2; and; 2, 1
-- Not doing that right now, causes other queries to be rewritten.
-- Hoping the ST_StartPoint()/ST_EndPOint() changes are enough to matter.
e1.id != e2.id
AND ST_DWithin(e1.geom, e2.geom, 0.1)
AND NOT (
e1.geom_start = e2.geom_start OR e1.geom_start = e2.geom_end
OR e1.geom_end = e2.geom_start OR e1.geom_end = e2.geom_end
)
;
SELECT 73268
Time: 1455.432 ms (00:01.455)
This works for me on the Berlin dataset. Only takes 3 minutes and 20 seconds now. Thanks for the improvements!
Just FYI, I wasn't able to pull this image as it couldn't be found, so I built it locally:
$ docker pull rustprooflabs/pgosm-flex:1.1.2
Error response from daemon: failed to resolve reference "docker.io/rustprooflabs/pgosm-flex:1.1.2": docker.io/rustprooflabs/pgosm-flex:1.1.2: not found
@travishathaway Thanks for the validation! Sorry, I should have been more clear about the Docker image, I had only pushed to the :latest tag not an officially tagged version. I think this is enough of an improvement that I'll get started on the official 1.1.2 release.
I'm going to close this issue as I think the initially reported problem is resolved. If you detect any future issues please either re-open this or create a new issue. Thanks again for your help!
Activity
[-]Documentation instructions for pgrouting no longer work[/-][+]Documentation instructions for pgrouting no longer work (pgrouting >=4)[/+][-]Documentation instructions for pgrouting no longer work (pgrouting >=4)[/-][+]Documentation instructions for routing no longer work (pgrouting >=4)[/+]rustprooflabs commentedon Dec 13, 2025
Thanks for the heads up, @travishathaway! I'll start playing around with it. I hadn't realized I accidentally bundled a big upgrade on the
pgroutingside. It's worth updating docs to keep up with the times.rustprooflabs commentedon Dec 13, 2025
Breadcrumbs to follow:
pgr_nodeNetworkremoved: Remove deprecated pgr_nodeNetwork pgRouting/pgrouting#2886 points at "Usepgr_separateCrossingandpgr_separteTouchinginstead"pgr_CreateTopologyremoved: Remove pgr_CreateTopology in 4.0 pgRouting/pgrouting#2751 - Refers topgr_extractVerticespgr_analyzeGraphremoved: Remove pgr_analyzeGraph in 4.0 pgRouting/pgrouting#2752 --rustprooflabs commentedon Dec 14, 2025
Updated 1.1.1 release notes so hopefully anyone else who looks before the docs are updated have a heads up.
See #411 for PR that will add the new documentation.
rustprooflabs commentedon Dec 14, 2025
The initial version of pgRouting 4.0 docs are live on this page. This uses the common starting point for both new and old.
If you have a chance to test and verify if this works for you that'd be fantastic. I'll do more thorough testing soon. I am pondering of a few new examples to add too.
travishathaway commentedon Dec 15, 2025
I should have some free time to test this out in the coming week. I will post my feedback here.
travishathaway commentedon Dec 19, 2025
@rustprooflabs,
I had the chance to try this out. I first attempted the Brandenburg dataset. I waited about 24 hours until I canceled it. After that I, I tried just Berlin and gave up after about 8 hours. So, I was unfortunately unable to finish.
This all got me thinking that it might be nice to have tips on how to reduce the graph size in the documentation. For example, I'm only interested in pedestrian routes, so maybe I just need to limit my network even further? I'll keep poking around at this and re-read your documentation to see if there's anything obvious about this in there I missed.
Based on what I come up with, I would be happy to submit a pull request to add more to the documentation with any tips or tricks that I discover.
rustprooflabs commentedon Dec 20, 2025
An observation -
pgr_separateTouching()takes a LOT longer to get the job done compared to the legacypgr_nodeNetwork()function. Scaling from D.C. road network to Colorado road network goes from ~1 hour to ??? hours (21 hours and counting).Using
dryrunshows the CTE query it's running, so I'm digging into that direction. I hadn't looked too closely at the legacy function, so might do some comparison to see what changed.This portion seems likely to be the bottleneck.
rustprooflabs commentedon Dec 20, 2025
@travishathaway Yeah, performance has unfortunately tanked in the step to create the noded network using these new functions. I'll keep digging into that side of things, per my other comment it's unusable for the region I want too, and I don't want it limited!
For pedestrian routes you can adjust your input query with filters on the boolean columns, e.g.
route_foot. I'd do that in the firstrouting.osm_road_intermediatestep and it should cascade through the process from there. Note that theroute_footlogic includes a variety of motorized roads in it's access controls. Depending on your area and how much dedicated footway infrastructure you have, you might want to includeAND NOT route_motor, or be more specific with specificosm_typefilters.rustprooflabs commentedon Dec 20, 2025
@travishathaway Here's what I'm doing for testing with a tiny dataset, limiting the roads to a single neighborhood. I add a join to the first query in the CTE to return under 200 road segments but still with a routeable data set..
rustprooflabs commentedon Dec 20, 2025
Sorry for all the noise -- but good news! I got the D.C. query down from 45 minutes to under 2 seconds. I'm going to try running this on the Colorado data, if it scales up well I'll publish a better version of the docs.
This query is the slow step from the
pgrfunction, note all theST_StartPoint()/ST_EndPoint()in theORclause. No wonder this doesn't perform well.This version doesn't show the changes that happened upstream, but the
geom_startandgeom_endcolumns are indexed geometries instead of on-the-fly calculations.CREATE TEMP TABLE get_touching_new AS SELECT e1.id AS id1, e2.id AS id2 , ST_Snap(e1.geom, e2.geom, 0.01) AS geom , e1.geom AS g1 , e2.geom AS g2 FROM routing.osm_road_intermediate e1 , routing.osm_road_intermediate e2 WHERE -- we could use < Instead of != to only report intersections. -- The != results in two rows, e.g. 1, 2; and; 2, 1 -- Not doing that right now, causes other queries to be rewritten. -- Hoping the ST_StartPoint()/ST_EndPOint() changes are enough to matter. e1.id != e2.id AND ST_DWithin(e1.geom, e2.geom, 0.1) AND NOT ( e1.geom_start = e2.geom_start OR e1.geom_start = e2.geom_end OR e1.geom_end = e2.geom_start OR e1.geom_end = e2.geom_end ) ; SELECT 73268 Time: 1455.432 ms (00:01.455)rustprooflabs commentedon Dec 20, 2025
Continuing to work on this under #413.
rustprooflabs commentedon Dec 21, 2025
@travishathaway New docker image pushed, see #413 (comment) for the notes on instructions, long term the docs are more important. I'd expect your regions to process in reasonable times now. 🤞
travishathaway commentedon Dec 22, 2025
@rustprooflabs,
This works for me on the Berlin dataset. Only takes 3 minutes and 20 seconds now. Thanks for the improvements!
Just FYI, I wasn't able to pull this image as it couldn't be found, so I built it locally:
rustprooflabs commentedon Dec 23, 2025
@travishathaway Thanks for the validation! Sorry, I should have been more clear about the Docker image, I had only pushed to the
:latesttag not an officially tagged version. I think this is enough of an improvement that I'll get started on the official 1.1.2 release.I'm going to close this issue as I think the initially reported problem is resolved. If you detect any future issues please either re-open this or create a new issue. Thanks again for your help!