User:Grille Chompa/Mapnik renderer windows

From OpenStreetMap Wiki
Jump to navigation Jump to search

This page lists the steps needed to set up an OSM-based Mapnik renderer on Windows using a PostGIS database as backend. I compiled these instructions using Windows 7:

Setting up the infrastructure: PostGIS

  • Download the latest (currently 8.4) Binary packages from PostgreSQL - Run the installer
  • Go to Start -> Programs -> PostgreSQL 8.4 -> Application Stack Builder. Select your PostgreSQL installation from the list and then click "Next". The latest version of PostGIS will appear under the "Spatial Extensions" category. Read the instructions and click "Next", "Next", Next" until the PostGIS installation has finished.

Setting up the infrastructure: Python

Setting up the database: PostGIS

  • Open Start -> Programs -> PostgreSQL 8.4 -> pgAdmin III
  • Rightclick on your local PostgreSQL server and select "Connect"
  • Rightclick "Databases" in the tree -> "New Database..."
  • Name it "gis", select "postgres" as owner and make sure the encoding is set to "UTF8"
  • Add the plpgsql language to your newly created database:
C:\Program Files\PostgreSQL\8.4\bin\createlang -U postgres plpgsql gis
  • Add the postgis tables to your database "gis":
C:\Program Files\PostgreSQL\8.4\bin\psql -U postgres -d gis -f "%ProgramFiles%\PostgreSQL\8.4\share\contrib\postgis-1.5\postgis.sql"

Setting up osm2pgsql

C:\Program Files\PostgreSQL\8.4\bin\psql -d gis -U postgres -f c:\osm2pgsql\900913.sql
  • Import your extract using:
C:\osm2pgsql>osm2pgsql.exe -d gis -U postgres -W -H localhost -P 5432 -S planet.osm.bz2

Setting up mapnik

  • Download the win32 binary
  • Place the unzipped folder into C:\mapnik-0.7.1\
  • Open python\2.6\site-packages\mapnik\ and confirm that the 'mapniklibpath' points to 'C:/mapnik-0.7.1/lib/mapnik'
  • Open Control Panel->System->Advanced->Environment Variables
  • Add C:\mapnik-0.7.1\lib to the variable PATH
  • Add C:\mapnik-0.7.1\python\2.6\site-packages" to the variable PYTHONPATH
  • Run C:\Python25\python.exe, then type at a python prompt:
from mapnik import *
  • Open explorer, go to C:\mapnik-0.7.1\demo\python, double click => you should see several demo.* files output.