I am new to all things GIS! However, I need to set up a full GIS infrastructure for a project.

I have installed a Postgres server with PostGIS. That is on ancient hardware for now, 32bits processor with 1GB of RAM, Ubuntu 12.04.

I have imported OSM data from geofabrik.de into my server using osm2pgsql.

The first issue I had was a problem with the osm.pbf files ("Document is empty"). I was more lucky with bz2. I "just" have an error message at the end but as it is at clean up time, I thought it was OK.

My command looks like this :

/usr/bin/osm2pgsql -d osm -s -K -S /usr/share/osm2pgsql/default.style languedoc-roussillon-latest.osm.bz2

The import log looks like this :

Committing transaction for planet_osm_polygon
Committing transaction for planet_osm_line
Committing transaction for planet_osm_roads
Sorting data and creating indexes for planet_osm_polygon
Sorting data and creating indexes for planet_osm_roads
Sorting data and creating indexes for planet_osm_line
Committing transaction for planet_osm_point
Sorting data and creating indexes for planet_osm_point
Completed planet_osm_point
Completed planet_osm_roads
Completed planet_osm_line
Completed planet_osm_polygon
Stopping table: planet_osm_nodes
Stopping table: planet_osm_ways
Stopping table: planet_osm_rels
COPY_END for COPY planet_osm_nodes FROM STDIN;
 failed: ERROR:  duplicate key value violates unique constraint "planet_osm_nodes_pkey"
DETAIL:  Key (id)=(2147483647) already exists.
CONTEXT:  COPY planet_osm_nodes, line 12179900

Error occurred, cleaning up
Stopped table: planet_osm_rels
Stopped table: planet_os_ways

Unfortunately, the data does not look good when I connect QGIS to my PosGIS DB.

It is very strange, but it seems that all polygons include one point at the center of the map.

I am not sure what is wrong or if it is related to the error that occurs at the end of the import.

  • Perhaps you can add a screenshot of what it looks like in QGIS? It could simply be a projection issue. By default osm2pgsql stores data in Spherical Mercator. – alphabetasoup Jan 31 '16 at 22:30

This is a well known issue in osm2pgsql. See https://github.com/openstreetmap/osm2pgsql/issues/16 . This issue is raised when osm2pgsql slim mode is used and multiple geometries are imported. Don't use osm2pgsql slim mode, then the issue will probably go away.

edit: Or it might be a stale version of osm2pgsql: https://help.openstreetmap.org/questions/24070/failed-error-duplicate-key-value-violates-unique-constraint . osm2pgsql was switched from 32bit to 64bit ID space some time ago, not all releases of osm2pgsql can handle 64 bit osm ids. Note this has nothing to do with the "bittiness" of your processor or operating system.

| improve this answer | |
  • 1
    This actually put me on the right track. In installes osm2psql from the official ubuntu repositories and the version was way outdated (by a few years IIRC). – jmc34 Feb 1 '16 at 12:33
  • 1
    I have used alternate repositories as described here switch2osm.org/loading-osm-data and it is now working fine (and it is much faster as well). – jmc34 Feb 1 '16 at 12:39

This page suggests a panel of ways to extract OSM data and display them into Desktop GIS. These are not necessarily based on command lines.

It might help you.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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