From OpenStreetMap Wiki
Jump to: navigation, search

When I tried to run osm2postgresql on my Kubuntu 11.4 system on 32bit intel, I ran into problems. The main problem, as I found out later, was a parameter passed to osmosis which did not work on my system. I had to modify osm2postgresql. The original osmosis call read

./$osmosis_version/bin/osmosis -v --read-$filetype file="$osmfile" --buffer --write-pgsql-dump enableBboxBuilder=yes enableLinestringBuilder=yes nodeLocationStoreType="TempFile" directory="$temporarydir"

I removed nodeLocationStoreType="TempFile", thereby using the osmosis default for the store type. With this modification I could use the script. I adopted this use procedure:

1. after I had installed postgres, I took the easy route and created a database user with my system username with database superuser privileges (creatueser --superuser). This way, I could proceed without any permission difficulties or finetuning, and all subsequent code worked smoothly.

2. I did the calls to create the database, install postgis, and hstore manually. (I suspect I could have let osm2postgresql do this as well)

  1. set environment variables, create database

dbname=piemonte # adapt as needed osmfile=$dbname.osm createdb $dbname createlang plpgsql $dbname

  1. install postgis, hstore and adminpack
  2. (you have to download the postgis and hstore packages first)

psql -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql -d $dbname psql -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql -d $dbname psql -d $dbname -f /usr/share/postgresql/8.4/contrib/hstore-new.sql

  1. for good measure I added this, not sure if it's needed:

psql -d $dbname -f /usr/share/postgresql/8.4/contrib/adminpack.sql

3. Now let osm2postgresql do the rest, working on the already-created and prepared database:

./ --dbname $dbname --file $osmfile

This did the trick and I now had the data in postgres accessible from QGIS.

--Kfj 10:38, 1 May 2012 (BST)