Skip to content
This repository

Mirror of the mapnik stylesheets formerly used on

Update the description. Now superceded

git-svn-id: b9d5c4c9-76e1-0310-9c85-f3177eceb1e4
latest commit 236f8d0ab1
harrywood authored
Octocat-spinner-32 all_tiles Move mapnik stuff to applications/rendering April 14, 2007
Octocat-spinner-32 archive Move a bunch of old and/or obsoleted items to an archive dir December 03, 2009
Octocat-spinner-32 debian improve debian packaging scripts January 25, 2012
Octocat-spinner-32 inc The name of the Natural Earth 110m boundary lines shape file changed January 28, 2013
Octocat-spinner-32 livetiles livetiles is a simple live renderer for mapnik tiles April 29, 2012
Octocat-spinner-32 symbols Add some amenity key values (veterinary, bench, waste_basket) December 05, 2012
Octocat-spinner-32 utils make regexes more versatile June 06, 2012
Octocat-spinner-32 README Update the description. Now superceded October 26, 2013
Octocat-spinner-32 use mapnik2 if present July 07, 2011
Octocat-spinner-32 allow bigger buffer-sizes to be specified in xml January 03, 2013
Octocat-spinner-32 allow bigger buffer-sizes to be specified in xml January 03, 2013
Octocat-spinner-32 update docs, remove warning February 26, 2013
Octocat-spinner-32 Update download locations for Natural Earth data November 27, 2012
Octocat-spinner-32 Tweak so it at least runs and produces output, just to see what it does. June 20, 2013
Octocat-spinner-32 Revert shield symbols and script back to previous, larger, size (-r 1… November 02, 2008
Octocat-spinner-32 osm.xml Add bridge=swing/lift (#4660) May 20, 2013
Octocat-spinner-32 bugfixes in November 27, 2011
Octocat-spinner-32 zoom-to-scale.txt Added comparison between zoom levels and the scale denominator number… December 21, 2007
Old XML format Mapnik stylesheets for OpenStreetMap 'standard' style

This used to be the development location of the Mapnik stylesheets
powering however these XML format stylesheets
have since be superceded by new CartoCSS format stylesheets which
can be found here:

These old XML stylesheets are still used on some other tile servers.

This directory also holds an assortment of helpful utility scripts for
working with Mapnik and the OSM Mapnik XML stylesheets.

Scalable large-area serving is typically done using mod_tile
 * Code is located at
 * Rendering is done by the 'renderd' daemon (both a python and C++ version are available).

However, the easiest way to start rendering Mapnik tiles is to use the 
'' script located within this directory.

Quick References
If you need additional info, please read:

If you are new to Mapnik see:

If you are looking for an old file that used to be here see the 'archive' directory.


Mapnik >= 2.0.0 | The rendering library
 * Built with the PostGIS plugin

osm2pgsql trunk | Tool for importing OSM data into PostGIS
 * The latest trunk source is highly recommended

Coastline Shapefiles
 * Download these locally
 * For more info see:
 * They come with Mapnik indexes pre-built (using shapeindex)

Planet.osm data in PostGIS
 * An extract (recommended) or the whole thing
 * Import this into PostGIS with osm2pgsql


The goal is to customize the Mapnik stylesheets to your local setup,
test rendering a few images, and then get set up to render tiles.

First, make sure you have downloaded the coastlines shapefiles and have set up a
postgis enabled database with osm data imported using osm2pgsql. See for more info.

Then customize the xml entities (the files in the inc/ directory) which are
used by the 'osm.xml' to your setup. You can either use the '' 
script or manually edit a few files inside the 'inc' directory.

Finally try rendering a few maps using either '',
'' or ''.

Downloading the Coastlines Shapefiles
    All these actions are regrouped in the script file in this directory

    wget # (51M)
    wget # (391M)
    wget # (42M)
    wget # (1.5 MB)
    wget # (44 KB)

    tar xzf world_boundaries-spherical.tgz # creates a 'world_boundaries' folder
    tar xjf processed_p.tar.bz2 -C world_boundaries
    tar xjf shoreline_300.tar.bz2 -C world_boundaries
    unzip -q -d world_boundaries
    unzip -q -d world_boundaries


To use the '' script simply run:

    ./ -h  # note the optional and required parameters

Most users will need to pass their database settings with something like:

    ./ --dbname osm --host 'localhost' --user postgres --port 5432 --password ''

If that command works, then you are ready to render tiles!

The script will also pick up ALLCAPS global environment settings (where they must have a 'MAPNIK" prefix):

    export MAPNIK_DBNAME=osm && export MAPNIK_HOST=localhost && ./ 

Note: Depending on your database configuration you may be able to leave empty values for
parameters such as 'host', 'port', 'password', or even 'dbname'.

Do do this can pass the '--accept-none' flag or empty strings:

    ./ --dbname osm --accept-none

    ./ --dbname osm --host '' --user '' --port '' --password ''

Advanced users may want to create multiple versions of the Mapnik XML for various rendering
scenarios, and this can be done using '' by passing the 'osm.xml' as an argument
and then piping the resulting xml to a new file:

    ./ osm.xml > my_osm.xml

Manually editing 'inc' files

To manually configure your setup you will need to work with the XML snippets 
in the 'inc' directory which end with 'template'.

Copy them to a new file and strip off the '.template' extension.

    cp inc/ inc/
    cp inc/ inc/
    cp inc/ inc/

Then edit the settings variables (e.g. '%(value)s') in those files to match your configuration.
Details can be found in each file. Stick with the recommended defaults unless you know better.


If trying to read the XML with Mapnik (or any of the python scripts included here that use Mapnik)
fails with an error like `XML document not well formed` or `Entity 'foo' not defined`, then try running
xmllint, which may provide a more detailed error to help you find the syntax problem in the XML (or its
referenced includes):

    xmllint osm.xml --noout

Not output from the above command indicates the stylesheet should be working fine.

If you see an error like: `warning: failed to load external entity "inc/"` then this
likely indicates that an include file is missing, which means that you forgot to follow the steps above to generate the needed includes on the fly either by using `` or manually creating your inc files.

Testing rendering

To generate a simple image of the United Kingdom use the '' script.

    ./ # will output and 'image.png' file...

To try generating an image with the ability to zoom to different areas or output different formats
then try loading the XML using nik2img. Download and install nik2img using the
instructions from

To zoom to the same area as but at level 4 do: osm.xml image.png --center -2.2 54.25 --zoom 4

Advanced users may want to change settings and dynamically view result of the re-generated xml.

This can be accomplished by piping the XML to, for example:

    ./ osm.xml | test.png

Or, zoom into a specific layer's extent (useful when using a regional OSM extract):

    ./ --estimate_extent true --dbname osm osm.xml --accept-none | --zoom-to-layer roads roads.png

Rendering tiles

You are now ready to test rendering tiles.

Edit the 'bbox' inside '' and run


Alternatively, run

    ./ --bbox X1 Y1 X2 Y2

Tiles will be written into 'tiles' directory. To see the list of all parameters,
run this script without any.

Files and Directories


    OBSOLETE. Use customize-mapnik-map instead.

    Run this script to convert osm-template.xml into osm.xml with your
    A script to help customize the osm.xml. Will read parameters from the
    users environment or via command line flags. Run ./ -h
    for usage and help.
    A script to generate a map image from OSM data using Mapnik. Will
    read mapping instructions from $MAPNIK_MAP_FILE (or 'osm.xml') and
    write the finished map to 'image.png'. You have to change the script
    to change the bounding box or image size.
    A script to generate map tiles from OSM data using Mapnik. Will
    read mapping instructions from $MAPNIK_MAP_FILE (or 'osm.xml') and
    write the finished maps to the $MAPNIK_TILE_DIR directory. You have
    to change the script to change the bounding boxes or zoom levels
    for which tiles are created.
    An advanced script to generate map tiles with Mapnik. Can produce
    png files, .mbtiles or just a list. Supports not only bboxes,
    but PostGIS polygons, .poly files and tile lists. Run the script
    without parameters to see the full list of options.

    An almost cut-and-paste documentation on how to use all this.
    Script for generating a simple legend from osm-template.xml, useful
    for visualizing existing styles and changes.
    Perl script to generate highway shield images. You normally don't
    have to run this because prerendered images are already stored in
    the 'symbols' directory.

    These directories contain the things needed to create Debian packages
    for OSM Mapnik stuff.

    A template for the osm.xml file which contains the rules on how
    Mapnik should render data.

    The file which contains the rules on how Mapnik should render data.
    You should generate your own version from the osm-template.xml file.
    Older script to read OSM data into a PostgreSQL/PostGIS database. Use
    the newer C version in ../../utils/export/osm2pgsql instead!

    Used to customize the environment needed by the other Mapnik OSM

    SQL commands to set up Z order for rendering. This is included in
    the C version of osm2pgsql in ../../utils/export/osm2pgsql, so you
    don't need this any more.

    Directory with icons and highway shield images.

    Comparison between zoom levels and the scale denominator numbers needed
    for the Mapnik Map file.
Something went wrong with that request. Please try again.