Skip to content

Instantly share code, notes, and snippets.

@zouzias
Last active November 24, 2016 15:16
Show Gist options
  • Save zouzias/84f0173cba3a6ff3d380bf898b83e159 to your computer and use it in GitHub Desktop.
Save zouzias/84f0173cba3a6ff3d380bf898b83e159 to your computer and use it in GitHub Desktop.
OpenStreetMap (OSM) to Postgres
#!/bin/bash
export PGPASSWORD=docker
psql -h localhost -p 5432 -U docker pgsnapshot
FROM postgres:9.6.1
RUN apt-get update
RUN apt-get install -y osmosis wget postgis
http://wiki.openstreetmap.org/wiki/Osmosis/PostGIS_Setup#Procedure_to_import_data_into_PostgreSQL
sudo apt install osmosis
createdb pgsnapshot
psql -d pgsnapshot 'CREATE EXTENSION postgis; CREATE EXTENSION hstore;'
psql -d pgsnapshot -f /usr/share/doc/osmosis/examples/pgsnapshot_schema_0.6.sql
psql -d pgsnapshot -f /usr/share/doc/osmosis/examples/pgsnapshot_schema_0.6_linestring.sql
wget https://planet.osm.ch/switzerland-exact.osm.pbf
osmosis --read-pbf extract.osm.pbf --log-progress --write-pgsql database=pgsnapshot
# wget https://planet.osm.ch/switzerland-exact.osm.pbf
export PGPASSWORD=docker
psql -h localhost -p 5432 -U docker -d pgsnapshot --command="CREATE EXTENSION postgis; CREATE EXTENSION hstore;"
psql -h localhost -p 5432 -U docker -d pgsnapshot -f /usr/share/doc/osmosis/examples/pgsnapshot_schema_0.6.sql
psql -h localhost -p 5432 -U docker -d pgsnapshot -f /usr/share/doc/osmosis/examples/pgsnapshot_schema_0.6_linestring.sql
osmosis --read-pbf ./switzerland-exact.osm.pbf --log-progress --write-pgsql database=pgsnapshot user="docker" password="docker"
#!/bin/bash
docker build . -t postgres-osm-swiss
docker run -i -t -p 5432:5432 -e POSTGRES_USER=docker -e POSTGRES_PASSWORD=docker -e POSTGRES_DB=pgsnapshot postgres-osm-swiss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment