OpenStreetMap (OSM) Install on Windows – Part II – Generate Tiles

Configure The Software

Now you have map data in your data [Part I], its time to generate the map tiles.

First of all, go get 7-Zip and install it as you are going to need it.

Next you will need to install MAPNIK, which is a cross platform toolkit for desktop and server based map rendering.  The Windows version is a bit behind but is still perfectly serviceable for our needs.

Download the software from here. Unpack it and add a path to its \lib directory. [The version was  mapnik-2.0.1rc0 when I downloaded]

set PATH=%PATH%;c:\mapnik-2.0.1rc0\lib

Now test to see if it works:

cd c:\mapnik-2.0.1rc0\demo\c++

rundemo ..\..\lib\mapnik

Once you are happy with this, you need to install the Python bindings from here. Once installed, add to your path and generate a required environment variable.

Add Python to your path [ C:\Python27 ]

Make a new environment variable PYTHONPATH pointing to c:\mapnik-2.0.1rc0\python\2.7\site-packages;

Check python / mapnik are OK with:

cd c:\mapnik-2.0.1rc0\demo\python

python rundemo.py

Before we can start generating tiles, we need just one more library. Make sure to add theproj.4 Cartographic Projections Library,  It can be found here.  Look for the proj446_win32_bin.zip: Prebuilt Win32 executables, DLL including NAD27 grid shift files.

Add the \bin directory to your path and make a new environment variable PROJ_LIB pointing to C:\proj\nad

Tile Rendering

Now we can get started on tile rendering.  You will need subversion for this.  Get the latest mapnik rendering tools using the following command:

svn export http://svn.openstreetmap.org/applications/rendering/mapnik

To render tiles from the database, you will also need some other information files for coastlines etc.  Download these and unpack into c:\mapnik\world_boundaries

http://tile.openstreetmap.org/world_boundaries-spherical.tgz

http://tile.openstreetmap.org/processed_p.tar.bz2

http://tile.openstreetmap.org/shoreline_300.tar.bz2

http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/10m-populated-places.zip

http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/110m-admin-0-boundary-lines.zip

Now perform a quick check to make sure everything is installed correctly.  Go to the C:\mapnik directory and execute the following command.

generate_xml.py -h

Now need to generate the osm.xml file which controls tile generation:  Type:

generate_xml.py –host localhost –user postgres –dbname gis –symbols symbols/ –world_boundaries world_boundaries/ –port 5432 –password ‘password’

You are now in a position to generate tiles. Run the  following to test image generation:

set MAPNIK_MAP_FILE=osm.xml

set MAPNIK_TILE_DIR=C:\tiles

set HOME=C:\Users

generate_image.py

If ok, generate tiles from the loaded database [can take a very very long time … we are talking days] using the following command.  Note that you will probably want to edit the bounding box entries [e.g. bbox = (…)] to control which areas you render tiles for and to what zoom level. render_tiles(…)

generate_tiles.py