[GIS] Problem with loading OSM planet into PostgreSQL

geosopenstreetmaposm2pgsqlpostgispostgresql

I try download OSM planet into PostgreSQL database.

I do all steps from instruction http://switch2osm.org/serving-tiles/manually-building-a-tile-server-12-04/

I also modify string "kernel.shmmax"

Now I try download:

osm2pgsql --slim -d gis -C 800 --number-processes 4 planet-latest.osm.pbf

But I have error:

Reading in file: planet-latest.osm.pbf
Processing: Node(2041920k 189.9k/s) Way(199297k 3.39k/s) Relation(47930 14.42/s)osm2pgsql: PolygonBuilder.cpp:261: geos::geomgraph::EdgeRing* geos::operation::overlay::PolygonBuilder::findShell(std::vector<geos::operation::overlay::MinimalEdgeRing*>*): Assertion `shellCount <= 1' failed.

Emergency stop(made a memory dump)

How can I solve this problem?

UPDATE

It is important to know, that the problem is in data. I use planet-latest.osm.pbf 10-Oct-2013 13:29 22G

When I download rostov.osm.bz2 there are no problem.

Which version of libgeos is usefull for me?

UPDATE 2

Well. It is interesting to know, that I try to download planet-131002.osm.pbf file. I verify md5. It is equal.

UPDATE 3

I instal the latest version of libgeos. It is 3.3.3-1. Then I try download planet-131002.osm.pbf, and then planet-130614.osm.pb

But I have the same problem.

Best Answer

I had the same problem, and here is how I solved it:

The problem lies in PolygonBuilder.cpp within the libgeos library. The line causing the problem has actually been fixed already, but the fix is not in the current ubuntu/debian repository that is installed via apt-get. Details of the change can be found here.

I downloaded the libgeos from github and built the package from source using their instructions. I then removed the installed version of libgeos-dev using apt-get autoremove. This actually removed a few other dependent packages that I later had to reinstall. (libgdal-dev) The important thing here is to rebuild the osm2pgsql package which links against libgeos library. I also recompiled mapnik, which needed the libgdal-dev library that I previously removed when autoremoving libgeos-dev. This step may or may not be necessary, but I wanted to make sure everything that used libgeos was recompiled. After these steps I got past roadblock.

Overall I wasted a couple weeks of effort since it took so long to load the planet file into the database. (Increasing the memory cache configuration really speeds things up.) I ran this command when importing.

osm2pgsql --silm -d gis -C 28000 --number-processes 8 /tile/planet-latest.osm.bz2

Recap.

  1. Remove installed version of libgeos-dev

    apt-get remove libgeos-dev

  2. Download and install libgeos from github

  3. Recompile and install osm2pgsql and possibly other packages that use libgeos.

  4. Import the database and wait...

Hopefully this will help you and others.

Related Question