3

I need to import parking polygons from OSM to PostGIS. But when I import data from Overpass API using ogr2ogr it keeps creating an empty table (with the expected columns as to per osmconf.ini). Import from an extract file (*.osm.pbf) is working fine. Why is the import of the Overpass response not working, and is there a better way to import specific OSM elements? The process is to be automated later.

Overpass API request (response saved to parkings.osm):

https://overpass.osm.ch/api/interpreter?data=[bbox];way[amenity=parking];out geom;&bbox=7.56204,46.72907,7.65333,46.78813

ogr2ogr command:

ogr2ogr -f PostgreSQL "PG:host=localhost port=5432 user=osm_import password=pwd dbname=somedb active_schema=osm" "parkings.osm" multipolygons -nln osm_parking_polygons -overwrite -skipfailures

1 Answer 1

2

Since you're using out geom; in your Overpass QL query, you're requesting a response in a format which is not 100% compatible with OSM XML 0.6 format. However, ogr2ogr doesn't understand these Overpass API specific format extensions.

For an OSM XML compatible response, you need to change your query to

(way[amenity=parking];>;);out meta;

instead of

way[amenity=parking];out geom;

You can also open your query in overpass turbo, and then hit Export -> "load data into an OSM editor: JOSM". This way, the overpass turbo will try to "repair" your query, and make it OSM XML compliant.

1
  • your query works perfectly, thanks! Oct 23, 2023 at 15:09

Your Answer

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

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