Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created November 1, 2010 07:23
Show Gist options
  • Save springmeyer/657772 to your computer and use it in GitHub Desktop.
Save springmeyer/657772 to your computer and use it in GitHub Desktop.
import a pbf file into postgis from geofabrik using osmosis and osm2pgsql
# note: there is work afoot to load pbf directly with osm2pgsql
# http://lists.openstreetmap.org/pipermail/dev/2010-October/020953.html
# but for now osmosis >= 0.37 works best
# install java/osmosis if you don't already have it
sudo apt-get install sun-java6-jre
wget http://bretth.dev.openstreetmap.org/osmosis-build/osmosis-0.37.zip
unzip osmosis-0.37.zip
cd osmosis-0.37
chmod +x bin/osmosis
cd bin
export PATH=`pwd`:$PATH
# grab a pbf
# region graphic: http://en.wikipedia.org/wiki/File:Census_Regions_and_Divisions.PNG
wget wget http://download.geofabrik.de/osm/north-america/us-south.osm.pbf
# read with osmosis and stream into osm2pgsql, note '-' arg to both
osmosis --read-bin us-south.osm.pbf --write-xml - | osm2pgsql --slim -d <dbname> -
@ikks
Copy link

ikks commented May 19, 2013

There is an additional wget In the line 16, moreover, it works just perfect, thanks.

@monkut
Copy link

monkut commented Jun 17, 2016

Ran across this and seems a bit old, just want to mention it seems that pbf files can now be loaded directly with osm2pgsql. No need for osmosis installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment