Skip to content

Instantly share code, notes, and snippets.

@pnorman
Created May 9, 2014 17:50
Show Gist options
  • Save pnorman/bb4e19d2993efeb17da3 to your computer and use it in GitHub Desktop.
Save pnorman/bb4e19d2993efeb17da3 to your computer and use it in GitHub Desktop.
Shell commands to set up and load OpenStreetMap data into a PostGIS database with osm2pgsql on Ubuntu 14.04 from scratch
sudo apt-get --no-install-recommends -y install software-properties-common
sudo add-apt-repository -y ppa:kakrueger/openstreetmap
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get --no-install-recommends -y install git unzip curl build-essential postgresql-9.3-postgis-2.1 postgresql-contrib-9.3 proj-bin libgeos-dev apache2 munin munin-node munin-plugins-extra libdbd-pg-perl sysstat iotop ptop osm2pgsql osmctools
sudo -u postgres createuser -s $USER
createdb gis
psql -d gis -c 'CREATE EXTENSION hstore; CREATE EXTENSION postgis;'
sudo munin-node-configure --sh | sudo sh
sudo service munin-node restart
sudo sed -i "s|Allow from.*|Allow from all|" /etc/munin/apache.conf
sudo service apache2 reload
sudo tee /etc/sysctl.d/60-overcommit.conf <<EOF
# Overcommit settings to allow faster osm2pgsql imports
vm.overcommit_memory=1
EOF
sudo sysctl -p /etc/sysctl.d/60-overcommit.conf
mkdir -p ~/osm
cd ~/osm
git clone https://github.com/gravitystorm/openstreetmap-carto.git
wget http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf
osmupdate planet-latest.osm.pbf new_planet-latest.osm.pbf
osm2pgsql --create --slim --flat-nodes ~/osm/flat_nodes.bin -C 14000 --number-processes 4 -S ~/osm/openstreetmap-carto/openstreetmap-carto.style --hstore --multi-geometry ~/osm/new_planet-latest.osm.pbf
@hallahan
Copy link

I'm unable to add kakreuger/openstreetmap

I get the following:

sudo add-apt-repository -y ppa:kakrueger/openstreetmap
Cannot add PPA: 'ppa:kakrueger/openstreetmap'.
Please check that the PPA name or format is correct.

@satriasoftware
Copy link

look through /etc/apt/sources.list and change "vivid" to "trusty"
/etc/apt/sources.list.d/kakrueger-ubuntu-openstreetmap-vivid.list

deb http://ppa.launchpad.net/kakrueger/openstreetmap/ubuntu vivid main to 
deb http://ppa.launchpad.net/kakrueger/openstreetmap/ubuntu trusty main

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