Skip to content

Instantly share code, notes, and snippets.

@gmcintire
Forked from springmeyer/osm.pbf to postgis
Created January 13, 2012 03:16
Show Gist options
  • Select an option

  • Save gmcintire/1604403 to your computer and use it in GitHub Desktop.

Select an option

Save gmcintire/1604403 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> -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment