Mapnik/Installation

From OpenStreetMap Wiki
Jump to: navigation, search
Available languages
English русский

This page describes various ways of installing the Mapnik rendering program.

Current Installation instructions are also available at the Mapnik wiki.

Please note that you need mapnik 2.0.0 if you want to work with current versions of osm.xml
Otherwise you get lots of errors. The following guides are therefore outdated! However, most 
Linux distributions will get you mapnik 2 and all necessary dependencies via their package 
manager. Too easy!

For Debian Sid

See also http://trac.mapnik.org/wiki/DebianInstallation

Mapnik 0.7.1 is already packaged so you can just install it!

# aptitude install python-mapnik

Mapnik 2.0 is also available.

# aptitude install python-mapnik2

Debian Lenny

Mapnik 0.5.1 is already packaged so you can just install it!

# aptitude install python-mapnik

For Debian Etch (oldstable) (Mapnik 0.5)

Configure your system with access to the backports.org repository (see http://www.backports.org/).

# apt-get update
# apt-get install python-mapnik

Feel free to contact dom@earth.li with problems about the Debian packages. Note: there are no packages for amd64 only i386

Compiling the old Mapnik 0.5 from source on Debian Etch (oldstable)

Besides the dependencies listed above for Mapnik 0.4, you need iostreams from the boost library (where are they listed ?)

# aptitude install libboost-iostreams-dev
# apt-get install postgresql-dev libfreetype6-dev libxml2-dev libtiff4-dev libboost-regex-dev libboost-filesystem-dev libboost-python-dev

2nd line was added and worked for me, beware Sletuffe 19:48, 7 November 2008 (UTC)

Next you need to create some symbolic links. The last one for GDAL is not needed for OSM, but if you have it installed on your system and want to use it with Mapnik, then you need that link too.

# cd /usr/lib
# ln -s libboost_filesystem.so libboost_filesystem-mt.so
# ln -s libboost_regex.so libboost_regex-mt.so
# ln -s libboost_iostreams.so libboost_iostreams-mt.so
# ln -s libboost_program_options.so libboost_program_options-mt.so
# ln -s libboost_thread.so libboost_thread-mt.so
# ln -s libboost_python.so libboost_python-mt.so
# ln -s libgdal1.3.2.so libgdal.so

Next compile and install Mapnik. "XMLPARSER=libxml2" at the end of each line, is only needed if you want to use XML entities in your style sheets. On etch you need g++-4.1 (not 3.x)

$ cd /path/where/you/unpacked/the/mapnik/0.5/source/
$ python scons/scons.py PGSQL_INCLUDES=/usr/include/postgresql PROJ_INCLUDES=/usr/include PROJ_LIBS=/usr/lib XMLPARSER=libxml2
# python scons/scons.py install PGSQL_INCLUDES=/usr/include/postgresql PROJ_INCLUDES=/usr/include PROJ_LIBS=/usr/lib XMLPARSER=libxml2


By default Mapnik is installed in /usr/local/lib so you need to add that path to /etc/ld.so.conf and run 'ldconfig' afterwards.

# echo "/usr/local/lib" >> /etc/ld.so.conf
# ldconfig


For Microsoft Windows (Windows 2000 and above)

Also check the installation instructions in the Mapnik wiki which may be slightly more detailed or up-to-date.

  • Download Python 2.7 (Mind that Mapnik doesn't run on older or newer Python versions):

http://www.python.org/download/releases/2.7.2/
Note: Currently there is no 64bit version of mapnik

  • Install to C:\Python27
  • Add the lib dir to your PATH

Start - Control Panel - System - Advanced - Environment Variables

Append the following to your Systemvariables PATH setting:

;C:\mapnik-2.0.1rc0\lib;C:\Python27;

Add mapnik to the PYTHONPATH setting, create variable if not existing

PYTHONPATH=C:\mapnik-2.0.1rc0\python\2.7\site-packages

If you get errors, try to put the new path values before the existing ones.


  • Execute the Python command line. In Start - Run enter:
C:\Python27\python.exe
  • Enter this command:
from mapnik import *

If it does not work, check the trouble shooting hints in the mapnik wiki.

  • Exit by pressing "Ctrl + Z" or entering "quit()"


See also: Mapnik Windows Installation instructions

Ubuntu

aptitude install pgsql-dev libboost1.37-dev libltdl7-dev proj python-cairo libcairomm-1.0-dev

http://www.kelvinism.com/tech-blog/installing-mapnik-ubuntu-710/
Full guide: http://weait.com/content/build-your-own-openstreetmap-server
http://weait.com/content/make-your-first-map

To be check: for Ubuntu 10.04, it seems that some required DejaVu fonts are not any more installed by default. Fixed by calling 'sudo apt-get install ttf-dejavu-extra'

openSUSE 11.0

You need to add following package repository:

http://download.opensuse.org/repositories/Application:/Geo/openSUSE_11.0/

and then just install mapnik.

openSUSE 11.1

You need to add following package repository:

http://download.opensuse.org/repositories/Application:/Geo/openSUSE_11.1/

and then just install mapnik.

openSUSE 11.2 (from source)

First, if you have not already done so, add the Geo repository:

sudo zypper ar http://download.opensuse.org/repositories/Application:/Geo/openSUSE_11.2/ "Geo"
sudo zypper refresh

Then, install the required dependencies. (Note: I compiled this list of dependencies after already having the Osm2pgsql dependencies installed. I do not know which of those you need.)

sudo zypper install libjpeg-devel libtiff-devel libpng-devel boost-devel python-cairo-devel cairomm-devel libicu-devel libtool

Use Subversion to fetch the latest stable version of Mapnik and OpenStreetMap's Mapnik-scripts. At the time of writing, that was 0.7.1.

svn export http://svn.mapnik.org/tags/release-0.7.1 mapnik-0.7.1
svn export http://svn.openstreetmap.org/applications/rendering/mapnik

Build the Mapnik Python module:

cd mapnik-0.7.1/
# in the following line, you can omit everything after "scons.py" if you do not want to optimize the build or want to run the build on other machines.
python scons/scons.py CXX="g++ -march=native -O2 -fomit-frame-pointer" configure
python scons/scons.py
sudo python scons/scons.py install
sudo ldconfig
cd ../mapnik/

Edit the Mapnik-based tile script (generate_tiles.py in the mapnik directory) to only generate the tiles you want. Open it, and look for the comment "Change the following for". You can use one of the commands below it or write your own. Be sure to add a '#'-sign in front of every line you do not need, otherwise you will be generating a lot of tiles you don't want.

For example, to generate zoom levels six through eightteen for the Benelux, add the following lines:

# To generate zoom levels 6 through 18 for the Benelux, add the following two lines:
bbox = ( 2.26, 49.23, 7.41, 53.74 )
render_tiles( bbox, mapfile, tile_dir, 6, 18, "Benelux" )

As you might have guessed, the "bbox" defines a bounding box or rectangle on the world using GPS coordinates for which tiles should be created. It is defined by the coordinates of the lower left and upper right corner of that rectangle. In this example, those are (2.26, 49.23) and (7.41, 53.74), respectively.

To generate tiles for other areas, add the coordinates between the parenthesis after "bbox" and change the six and eightteen in the line below the bbox to correspond to the minimum and maximum zoom levels you want.

Another example, generating tiles for the entire world for zoom levels zero through five:

# To generate zoom levels 0 to 5 for the entire world
bbox = ( -180.0, -90.0, 180.0, 90.0 )
render_tiles( bbox, mapfile, tile_dir, 0, 5, "World" )

Gentoo

Mapnik 0.7.1 is already packaged so you can just install it! At the moment this is still marked unstable, so you might need to adapt your accept keywords.

# emerge mapnik

FreeBSD

On FreeBSD Mapnik is available for installing from source and from ports.

For installing from Mapnik from port, enter following command:
#cd /usr/ports/graphics/mapnik
#make
#make install
For installing from source go to mapnik.org to get needed archive of source (e.g. mapnik-0.7.1.tar.bz2), and enter following command:
#cd "full path to mapnik-0.7.1.tar.bz2"
#tar zxvf mapnik-0.7.1.tar.bz2
#cd mapnik-0.7.1.tar.bz
#python scons/scons.py configure
#python scons/scons.py 
#python scons/scons.py install

For check of a correctness of installation do the operations described in the document Mapnik:_Rendering_OSM_XML_data_directly.

Fedora 18

For more specific installation steps on Fedora 10, follow these steps: Mapnik/Fedora Installation.