This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

osm2pgsql how import relations into polygon table

0

I'm trying to import a relation of type multipolygon into a PostGreSQL DB using osm2pgsql.

I use the result of this query as OSM file: http://overpass-turbo.eu/s/G7r which contains one way https://www.openstreetmap.org/way/25210902 and one relation https://www.openstreetmap.org/way/25210902 with the default.style and this command: osm2pgsql --slim --username xy --database gis --style default.style export.osm

While the way item is going nicely into the table planet_osm_polygon, the relation doesn't import into planet_osm_polygon (or any other table), but is present in planet_osm_rels.

Also, there seems to be no error in the shape of the relation which would prevent the import, as checked on http://tools.geofabrik.de/osmi/?view=areas&lon=9.59871&lat=47.23608&zoom=16

My question: Is it by design that multipolygons do not end up in planet_osm_polygon or do I have to change the default.style or is there a problem with relation 1697460 (Although I also tested other multipolygon relations with the same (negative) result.)

asked 14 Feb '19, 15:46

r1tter's gravatar image

r1tter
51113
accept rate: 100%

edited 16 Feb '19, 08:59

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554


One Answer:

1

OK, the problem was the order of the data in the OSM XML file provided by overpass-turbo.eu (I selected "Export/Data/Download as raw OSM Data): When the relations appear BEFORE the nodes and ways, the relations won't be imported into planet_osm_polygon by osm2pgsql. Putting the relations AFTER the nodes and ways solved therefor the problem.

(Importing the OSM XML from overpass-turbo to level0.osmz.ru and then exporting the data as OSM corrected the order, btw)

answered 15 Feb '19, 15:27

r1tter's gravatar image

r1tter
51113
accept rate: 100%

thanks for the self-answer! Is there anything left unclear or can we close this question?

(15 Feb '19, 20:59) aseerel4c26 ♦

You can close it. Thanks!

(16 Feb '19, 06:48) r1tter

Source code available on GitHub .