I have little experience with postgres and none with pgrouting.

I'm trying to use the pgr_drivingDistance function with Open Street Map data (generated through osm2po), but whenever I run my query:

SELECT pgr_drivingDistance('SELECT id, osm_source_id::int4 AS source, osm_target_id::int4 AS target, cost::float8 AS cost FROM nyc_2po_4pgr', 85, 2, false, false);

I get ERROR: integer out of range—I assume because some of the osm_source_ids I'm getting in don't fit in an int4. Is that what's going on?

I'm using a small subsection of the OSM data, so I assume I could squash the source_ids/target_ids into an int4 range. How would I do that?

Alternatively, is there a way to make the pgr_drivingDistance work with the larger source/target ids?

1 Answer 1


osm_source_id::int4 casts an 8-Bytes-Long-Integer down to a 4-Byter. Hence the error message is correct. Anyway, osm_source_id is the wrong attribute. Use source (target) instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.