Last active
December 20, 2015 01:29
-
-
Save isedwards/6049594 to your computer and use it in GitHub Desktop.
OSM Bright - imposm - Postgres/PostGIS - Mapnik - TileMill - MBTiles script (ubuntu)
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
mkdir tile_cache | |
cd tile_cache | |
# Download Open Street Map Data | |
mkdir osm_data | |
cd osm_data | |
wget http://download.geofabrik.de/europe/great-britain/england/devon-latest.osm.pbf | |
wget http://download.geofabrik.de/europe/great-britain/england-latest.osm.pbf | |
cd .. | |
# Install TileMill | |
sudo add-apt-repository ppa:developmentseed/mapbox | |
sudo apt-get update | |
sudo apt-get install tilemill libmapnik nodejs | |
# Install Postgres: https://help.ubuntu.com/community/PostgreSQL | |
sudo apt-get install postgresql | |
##sudo apt-get install pgadmin3 | |
# Install imposm | |
sudo apt-get install aptitude | |
sudo aptitude install build-essential python-dev protobuf-compiler \ | |
libprotobuf-dev libtokyocabinet-dev python-psycopg2 libgeos-c1 | |
sudo apt-get install python-pip | |
sudo pip install imposm | |
# Download OSM Bright | |
mkdir osm_bright | |
cd osm_bright | |
wget https://github.com/mapbox/osm-bright/zipball/master | |
unzip master | |
rm master | |
ln -s mapbox-osm-bright-* mapbox-osm-bright | |
cd .. | |
# Update Postgres access permissions | |
sudo sed -i '/local all postgres/c\local all postgres trust' /etc/postgresql/9.1/main/pg_hba.conf | |
sudo sed -i '/local all all/c\local all all trust' /etc/postgresql/9.1/main/pg_hba.conf | |
sudo sed -i '/host all all 127/c\host all all 127.0.0.1/32 trust' /etc/postgresql/9.1/main/pg_hba.conf | |
sudo sed -i '/host all all ::1/c\host all all ::1/128 trust' /etc/postgresql/9.1/main/pg_hba.conf | |
sudo /etc/init.d/postgresql restart | |
# Set up PostGIS database | |
psql -U postgres -c "create database osm;" | |
psql -U postgres -d osm -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql | |
psql -U postgres -d osm -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql | |
# Import OSM data into PostGIS (Devon took 3.5 mins, England 3 hours 7 mins) | |
cd osm_data | |
echo "Note: Use empty passwork for postgres" | |
# Devon data | |
imposm -U postgres -d osm -m ~/tile_cache/osm_bright/mapbox-osm-bright/imposm-mapping.py --read --write --optimize --deploy-production-tables devon-latest.osm.pbf | |
# Or, England data | |
##imposm -U postgres -d osm -m ~/tile_cache/osm_bright/mapbox-osm-bright/imposm-mapping.py --read --write --optimize --deploy-production-tables england-latest.osm.pbf | |
cd .. | |
#Launch TileMill to create settings folders | |
bash -c "/usr/bin/nodejs /usr/share/tilemill/index.js >> $HOME/.tilemill.log 2>&1" & | |
# Setup OSM Bright | |
cd osm_bright/mapbox-osm-bright | |
cp configure.py.sample configure.py | |
sed -i '/config\["importer"\] = "osm2pgsql"/c\config["importer"] = "imposm"' configure.py | |
sed -i '/config\["postgis"\]\["user"\] = ""/c\config["postgis"]["user"] = "postgres"' configure.py | |
./make.py | |
echo "Reopen TileMill to see the new OSM Bright project" | |
echo "The map may take some time to appear, you will see messages like 'caching 2 resources...'" | |
echo "Next See: http://www.mapbox.com/tilemill/docs/guides/osm-bright-ubuntu-quickstart/#step_4_customize_your_map" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://imposm.org/docs/imposm/latest/