Last active
November 24, 2016 15:16
-
-
Save zouzias/84f0173cba3a6ff3d380bf898b83e159 to your computer and use it in GitHub Desktop.
OpenStreetMap (OSM) to Postgres
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export PGPASSWORD=docker | |
psql -h localhost -p 5432 -U docker pgsnapshot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM postgres:9.6.1 | |
RUN apt-get update | |
RUN apt-get install -y osmosis wget postgis |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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