Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
D
Documentation
  • Project overview
    • Project overview
    • Details
    • Activity
  • Analytics
    • Analytics
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • UB Database Group
  • Documentation
  • Wiki
  • OSM Tiles

Last edited by Oliver Kennedy Mar 31, 2021
Page history

OSM Tiles

Entry-point here:

  • https://github.com/ncareol/osm-tiles-docker/blob/master/Dockerfile

Load OSM data into Postgis

Step one of this process seems to be 'osm2pgsql'

  • https://osm2pgsql.org/
git clone git://github.com/openstreetmap/osm2pgsql.git

osm2pgsql docs: https://osm2pgsql.org/doc/manual.html

Dependencies (replace XX with the appropriate version #s):

sudo apt install postgresql-XX postgresql-XX-postgis-XX postgresql-contrib
sudo apt install make cmake g++ libboost-dev libboost-system-dev \
  libboost-filesystem-dev libexpat1-dev zlib1g-dev \
  libbz2-dev libpq-dev libproj-dev lua5.3 liblua5.3-dev pandoc

Build:

mkdir build
cd build
cmake ..
make
make man
sudo make install

Set up Postgresql (https://osm2pgsql.org/doc/manual.html#preparing-the-database):

# this assumes you want things in a database named 'osm' that your current user role has permissions for
sudo -u postgres createdb --encoding=UTF8 osm
postgres psql osm --command='CREATE EXTENSION postgis;'
postgres psql osm --command='CREATE EXTENSION hstore;'

There is additional tuning guidance here: https://osm2pgsql.org/doc/manual.html#preparing-the-database

List of OSM repositories:

  • https://wiki.openstreetmap.org/wiki/Planet.osm

Shape files by region available here:

  • https://download.geofabrik.de/

(either way, you're looking for the PBF file)

Do the load (again, assuming database osm):

osm2pgsql [[data_file.osm.pbf]] -d osm

Map Data Rendering

The tool used here seems to be Mapnik: https://mapnik.org/

Install easy Mapnik dependencies

sudo apt install libharfbuzz-dev libboost-regex-dev libboost-program-options-dev libcairo2-dev libgdal-dev

Mapnik also relies on ICU (unicode support)

  • Download here: https://github.com/unicode-org/icu/releases/
  • Several precompiled releases are available. Untarball and put the icu directory in the mapnik directory

Finally, Mapnik relies on (ugh) python 2.7. This is probably going to cause bit-rot on these instructions, but for now installing python2.7 with pyenv seems to work:

git clone https://github.com/pyenv/pyenv.git ~/.pyenv
cd ~/.pyenv && src/configure && make -C src
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
source ~/.bash_profile
sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
  libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
  xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
pyenv install 2.7.18

Finally download mapnik and install it (as of the time of writing, the python bindings were incompatible with the main branch):

cd mapnik
pyenv local 2.7.18
git checkout v3.0.x
./configure
make

Installing is tricky, since pyenv and sudo don't play nice.

sudo bash
PATH=$PATH:~[[YOUR_USERNAME_HERE]]/.pyenv/shims
make install

It looks like there's some extra style information

sudo apt install subversion unzip
svn co http://svn.openstreetmap.org/applications/rendering/mapnik mapnik-style
cd mapnik-style
./get-coastlines.sh

Get mapnik's python bindings: https://github.com/mapnik/python-mapnik

sudo apt install libboost-python-dev libboost-thread-dev
export BOOST_PYTHON_LIB=boost_python
Clone repository
  • 2016 Ketter133A
  • 2018 JITD Testbed Sketch
  • Annotation Provenance
  • Conferences
  • Datasets
  • Deploy a Service on Gram
  • FacilitiesStatement
  • GraphingTools
  • HTTPServerSourceCode
  • Hardware
  • LibraryGatewayHack
  • Machine Dumbo
  • Machine Gram
  • Machine Gungnir
  • Machine Mjolnir
View All Pages