OSM Mapnik

Table Of Contents

Previous topic

Working with VirtualBox

Next topic

Configuring the Tools

Installing the Tools

The stack of tools making up the OpenStreetMap rendering toolchain can run on Windows (mostly), Linux (nicely), and Mac OS X.

This guide highly recommends running Ubuntu Lucid Linux (and installing “apt” packages), but also covers using installers for Windows and Mac OS X.

This plan sound good? Great, then lets begin by Installing the Tools

Choose your operating system: Windows, Ubuntu Linux, or Mac OS X.

When you are done installing, head next to Downloading OSM Extracts.



For Windows you can find all the installers within the “software” folder on your Desktop.


Mapnik works with both Python 2.5 and Python 2.6, but the installer below expects 2.5 so install Python2.5 from:


Windows installers for the latest release of PostgreSQL:

Run the installer:
  • Use osm as the postgres password
  • Use defaults for all other options, e.g. keep default port of 5432
  • Once finished, your computer should have a new user called ‘postgres’
  • You don’t have to ever log in as this user, just leave it alone.
  • If you see an error about “permission denied” in a terminal window see Troubleshooting PostgreSQL startup on Windows


The PostgreSQL windows installer can install PostGIS via the web using the Stackbuilder.

But, if you can also grab the installer directory:


Both Postgis 1.4.x and 1.5.x should be fine to use.

If installing from the Stackbuilder:

  • Go to Start ‣ Programs ‣ PostgreSQL 8.4 ‣ Application Stack Builder
  • In the first window from the drop down choose “PostgreSQL 8.4 on port 5432”
  • In the next window find and choose “Spatial Extensions > PostGIS (any version is okay)”
  • Choose any mirror, then move through the rest of the install keeping defaults

Once the installer is running:

  • Make sure to keep the blue checkbox checked that says “Create Spatial Database”
  • User: postgres
  • Port: 5432
  • password for postgres user: osm
  • Choose “Yes” to the prompt about adding support for “shp2pgsql”

Mapnik & osm2pgsql

Standalone installer for Mapnik, osm2pgsql, and various python tools (nik2img,tilelite,cascadenik):


Sorry, mod_tile is not available on Windows. An alternative is to use TileLite, which was just installed by the Mapnik installer.


Standalone installer for QuantumGIS:

Ubuntu Linux


The workshop VirtualBox Image already has all these packages installed, but there is no harm re-installing

On ubuntu life is good because we can let the APT package manager (and the wisdom behind those who maintain it) do all the hard work.

Update and upgrade package sources:

sudo apt-get update
sudo apt-get -y upgrade

Grab a bunch of base packages:

sudo apt-get install -y subversion python-setuptools \
build-essential wget curl vim unzip g++ cpp mercurial \
libboost1.40-dev libboost-filesystem1.40-dev \
libboost-iostreams1.40-dev libboost-program-options1.40-dev \
libboost-python1.40-dev libboost-regex1.40-dev \
libboost-thread1.40-dev libxml2 libxml2-dev \
libfreetype6 libfreetype6-dev libjpeg62 libjpeg62-dev \
libltdl7 libltdl-dev libpng12-0 libpng12-dev \
libgeotiff-dev libtiff4 libtiff4-dev libtiffxx0c2 \
libcairo2 libcairo2-dev python-cairo python-cairo-dev \
libcairomm-1.0-1 libcairomm-1.0-dev ttf-dejavu ttf-dejavu-core \
ttf-dejavu-extra  python-nose libbz2-dev autoconf  libsigc++-dev \
libsigc++0c2 libsigx-2.0-2 libsigx-2.0-dev libgdal1-dev \
proj libsqlite3-dev postgresql-8.4 postgresql-server-dev-8.4 \
postgresql-contrib-8.4 postgresql-8.4-postgis gdal-bin python-gdal \
apache2 apache2-threaded-dev apache2-mpm-prefork apache2-utils \
python-dev python-psycopg2 libapache2-mod-wsgi imagemagick php5-cli

Then compile the latest Mapnik:

svn co http://svn.mapnik.org/tags/release-0.7.1/ mapnik-0.7.1
cd mapnik-0.7.1
python scons/scons.py configure INPUT_PLUGINS=all OPTIMIZATION=3
sudo python scons/scons.py install
sudo ldconfig
cd ..


Make sure to uninstall any previous versions of Mapnik if present.

If you have installed Mapnik from packages do:

sudo apt-get remove libmapnik* python-mapnik

Or if you manually compiled do:

sudo rm /usr/local/lib/libmapnik.* # older mapnik versions will be in 'lib64'
sudo rm -rf /usr/local/lib/mapnik/
sudo rm -rf /usr/local/include/mapnik/
sudo rm -rf /usr/lib/python2.6/dist-packages/mapnik/

Install a few python tools for working with Mapnik:

sudo easy_install cssutils PIL cascadenik nik2img tilelite werkzeug pygments

Compile the latest osm2pgsql:

svn co http://svn.openstreetmap.org/applications/utils/export/osm2pgsql osm2pgsql-trunk
cd osm2pgsql-trunk
sudo make install
cd ..

Compile the latest mod_tile:

svn co http://svn.openstreetmap.org/applications/utils/mod_tile mod_tile-trunk
cd mod_tile-trunk
sudo make install
sudo bash -c "echo 'LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so' > /etc/apache2/mods-available/tile.load"
sudo a2enmod tile
sudo /etc/init.d/apache2 restart

Download Spreadnik:

svn co http://svn.openstreetmap.org/applications/utils/spreadnik/

Finally, grab QGIS:

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install qgis


QGIS should then appear in your menu under the Science catagory.

If finished, head along to Configuring the Tools.

Mac OS X

Great additional writeup for OS X is available at mojodna.net

Kyngchaos Frameworks

Install “GDAL Complete” linked from here:

Mapnik & osm2pgsql

Standalone installer for Mapnik and osm2pgsql:

Also install a few python tools for working with Mapnik:

sudo easy_install cssutils PIL cascadenik nik2img tilelite werkzeug pygments mercurial


Sorry, mod_tile is not available on Mac. An alternative is to use TileLite, which was just installed above using easy_install.


Grab from svn:

svn co http://svn.openstreetmap.org/applications/utils/spreadnik/


Standalone installer for QuantumGIS:

Next Steps

If finished, head along to Configuring the Tools.