Skip to content
Daniele Santini edited this page Jan 19, 2019 · 7 revisions

Dependencies

You need osm2pgsql, PostgreSQL and PostGIS installed.

Install scripts also need: bash, wget, unzip, gdal, shapeindex (in mapnik-utils)

Install on Ubuntu 14.04

sudo apt install postgresql-client-9.3 postgresql-9.3-postgis-2.1 osm2pgsql

Install on Ubuntu 14.10

sudo apt install postgresql-client-9.4 postgresql-9.4-postgis-2.1 osm2pgsql

Install on Fedora 28

sudo dnf install osm2pgsql postgresql-contrib postgis gdal mapnik-utils
sudo postgresql-setup --initdb
sudo systemctl start postgresql.service

Database setup

If you don't have a user yet, create one:

sudo -u postgres createuser {youruser}

Then create the db (we are using hdm as name, but you can use what you want):

sudo -u postgres createdb hdm -O {youruser}

Activate postgis and hstore extensions:

sudo -u postgres psql hdm
hdm=# CREATE EXTENSION postgis;
hdm=# CREATE EXTENSION hstore;

Download data

Get the data of the area you want, from one of those sites:

You need to download the .osm.pbf file of the area you want. For example, for Burundi, we use http://download.openstreetmap.fr/extracts/africa/burundi.osm.pbf

Import

osm2pgsql -G -U {youruser} -d hdm path/to/file-latest.osm.pbf --hstore --create