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

error with osm2pgsql

0

Hi!

I use https://protomaps.com/extracts to get extracts of 4 small areas. I merge those with "osmium" into one .osm.pbf that i import with osm2pgsql. This works great with 3 of those extracts, but after adding the 4th I get the following error when importing the data: DB writer thread failed due to ERROR: result COPY_END for planet_osm_rels failed: ERROR: duplicate key value violates unique constraint "planet_osm_rels_pkey" DETAIL: Key (id)=(21510) already exists. CONTEXT: COPY planet_osm_rels, line 43

Any idea how to fix this?

Tobias

asked 17 Jun '21, 09:50

Marx1st's gravatar image

Marx1st
11112
accept rate: 0%

Difficult to say without all the details like the file contents, osm2pgsql version used, command line used etc.

Chances are you have different versions of the same object in the input files. This can happen when you downloaded those areas at different points in time.

(18 Jun '21, 07:50) Jochen Topf

Yeah, I don't think it is a bug, but rather a problem with the "workflow" I've chosen. I've now downloaded the boundaries as .geojson and used those with "osmium extract" on a .pbf of Germany (from Geofabrik) and merged those files with "osmium merge". That .pbf can be imported without problems into the database... So, I've found a solution for that problem, but ain't that happy about it. It's too complicated for the client I'm building this for, to add new extracts...

(19 Jun '21, 12:37) Marx1st

Source code available on GitHub .