Skip to content

Instantly share code, notes, and snippets.

Last active Dec 11, 2015
What would you like to do?
Installing OSM Rendering Toolchain on Ubuntu 12.04 (13.01.2013)
# be fully up to date before starting:
sudo apt-get update
sudo apt-get upgrade
apt-get install wget
# ensure add-apt-repository is installed:
sudo apt-get install -y python-software-properties
# Mapnik v2.1.0
sudo add-apt-repository ppa:mapnik/v2.1.0
sudo apt-get update
sudo apt-get install libmapnik mapnik-utils python-mapnik
# Font Pfad anlegen
mkdir -p /usr/lib/mapnik/fonts
ln -s /usr/share/fonts/truetype/unifont/*.ttf /usr/share/fonts/truetype/ttf-dejavu/*.ttf /usr/lib/mapnik/fonts/
# Postgres und Postgis:
# Quelle:
sudo apt-get install postgresql-9.1-postgis postgresql-contrib-9.1
sudo -u postgres -i -H
createuser -SdR gisuser
createdb -E UTF8 -O gisuser gis
psql -d gis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
# to populate the table spatial_ref_sys (mandatory for use with osm2pgsql):
psql -d gis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
psql gis -c "ALTER TABLE geometry_columns OWNER TO gisuser"
psql gis -c "ALTER TABLE spatial_ref_sys OWNER TO gisuser"
# In Datei /etc/postgresql/9.1/main/pg_hba.conf
local all all trust
host all all trust
# Postgres Config tunen:
mcedit /etc/postgresql/9.1/main/postgresql.conf
shared_buffers = 1024MB
maintenance_work_mem = 1024MB
work_mem = 1024MB
checkpoint_segments = 20
autovacuum = off
# sudo mcedit /etc/sysctl.conf
kernel.shmmax = 3758096384
# Neustart:
sudo reboot
# Compiling Osm2pgsql
# Quelle:
# need the following dependencies:
apt-get install build-essential libxml2-dev libgeos++-dev libpq-dev libbz2-dev proj libtool automake
apt-get install git-core
cd /data/src
git clone
cd osm2pgsql/
sed -i 's/-g -O2/-O2 -march=native -fomit-frame-pointer/' Makefile
make install
mkdir /data/raw_osm_data
cd /data/raw_osm_data
sudo -u postgres -i
osm2pgsql --slim -d gis -C 20000 --number-processes 3 /data/raw_osm_data/germany.osm
# Tirex:
# Quelle:
apt-get install subversion
svn co osm-mapnik2
sudo mv osm-mapnik2 /usr/share/
cd /usr/share/osm-mapnik2
cp inc/ inc/
cp inc/ inc/
cp inc/ inc/
# edit inc/
<Parameter name="type">postgis</Parameter>
<Parameter name="password"></Parameter>
<Parameter name="host">/var/run/postgresql/</Parameter>
<Parameter name="port"></Parameter>
<Parameter name="user">gisuser</Parameter>
<Parameter name="dbname">gis</Parameter>
<Parameter name="estimate_extent">false</Parameter>
<Parameter name="extent">-20037508,-19929239,20037508,19929239</Parameter>
# edit inc/
<!ENTITY symbols "/usr/share/osm-mapnik2/symbols">
<!ENTITY osm2pgsql_projection "&srs900913;">
<!ENTITY dwithin_900913 "0.1">
<!ENTITY dwithin_4326 "0.00001">
<!ENTITY dwithin_node_way "&dwithin_900913;">
<!ENTITY world_boundaries "/usr/share/osm-mapnik2/world_boundaries">
<!ENTITY prefix "planet_osm">
# Hole World Boundaries:
apt-get install unzip
cd /usr/share/osm-mapnik
# Das eigentliche Tirex:
apt-get install debhelper devscripts libipc-sharelite-perl libjson-perl libgd-gd2-perl libwww-perl libboost-program-options-dev
apt-get install libmapnik-dev
cd /data/src
svn co
cd tirex
# Patch einspielen:
patch -p0 < tirex.diff
make deb
make deb-clean
cd ..
dpkg -i tirex-backend-mapnik_0.4.1*.deb tirex-core_0.4.1*.deb tirex-example-map_0.4.1*.deb
# Tirex Config bearbeiten
# mcedit /etc/tirex/renderer/mapnik/osm.conf
# Tiles Cache Verzeichnis auf /data anlegen:
mkdir /data/tirex_tiles
mkdir /data/tirex_tiles/osm
chown tirex:tirex /data/tirex_tiles/osm
ln -s /data/tirex_tiles/osm /var/lib/tirex/tiles/osm
# ??? chown tirex:tirex /var/lib/tirex/tiles/osm
# Tirex neu starten
/etc/init.d/tirex-master restart
/etc/init.d/tirex-backend-manager restart
tirex-status --once --extended
# Keep in mind:
If you want to add a new key but avoid re-importing the full database,
you can add the key to osm2pgsql's style file, somehow generate an .osm
file that contains only the objects that have this tag, wrap this .osm
file into a "<osmChange><modify>...</modify></osmChange>" instead of
"<osm>...</osm>" and throw it at osm2pgsql in append mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment