I’m using osm2pgsql to import OpenStreetMap (OSM) data into a PostgreSQL database for analysis. Despite configuring and importing the data correctly, I’m not seeing all the expected restrictions within a specified bounding box.
Setup and Configuration:
osm2pgsql Command:
osm2pgsql -U postgres -W -d osm_data -H localhost -s -G --number-processes 30 -C 102400 dach-latest.osm.pbf
Modifications to default.style:
node,way restriction text linear
node,way restriction:conditional text linear
PostgreSQL Database Schema:
planet_osm_line table includes columns like restriction and restriction:conditional, both of type text.
The geometry column way is of type geometry(LineString, 3857).
SQL Query:
I use the following query to fetch distinct restrictions within a bounding box:
SELECT DISTINCT restriction, "restriction:conditional"
FROM planet_osm_line
WHERE highway IN ('motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'unclassified',
'residential', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link')
AND ST_Intersects(way, ST_Transform(ST_MakeEnvelope(10.91492, 47.41136, 13.41705, 49.07207, 4326), 3857));
Issue:
restriction | restriction:conditional
-----------------+----------------------------------------------------
only_right_turn |
| restriction:conditional=no_parking @ (19:00-06:00)
|
(3 rows)
I have verified the presence of more restrictions within this bounding box using an external tool https://ahorn.lima-city.de/tr/ which shows a greater variety of restrictions.
What I’ve Tried:
-
Updating Data: Ensured my database is up-to-date with the latest OSM data.
-
Query Adjustments: Simplified and expanded the query to include all potential restrictions without the highway filter.
Question:
What could be causing the discrepancy between the restrictions visible in the external tool and those retrieved from my PostgreSQL database? Are there any additional configurations or steps I should consider to ensure all relevant restrictions are captured?
Any insights or suggestions would be greatly appreciated!