-
Notifications
You must be signed in to change notification settings - Fork 50
When tiles aren't enough
Use your web map stylesheet to render larger raster images and export to PDF, EPS, and SVG.
Use mapnik-render.py, available in the Toner repo »
You'll need to have the following dependencies already installed (the same ones for Mapnik and TileStache):
- mapnik
- cairo
- pyproj
- PIL (python imaging library, careful which version with what binary compile flags)
- ModestMaps
python mapnik-render.py -f fonts -s style.xml -l 0 0 -z 1 -d 1024 600 -o output.png
mapnik-render.py is a python file, so we ask python to run it.
-f fonts is the relative file path to the fonts directory.
-s style.xml is the XML stylesheet that condenses the MSS and MML into Mapnik native instructions, with relative file path.
-l 0 0 is the location of the map center in latitude followed by longitude, here the equator and the prime meridian.
-z 1 is the zoom in the standard 0 to 19 steps. NOTE: More about web map zooms and their natural scale equivalents »
-d 1024 600 is the dimensions (size) as width followed by height of the rendered map.
-o output.png is the output filename and the FORMAT of the rendered map.
The following raster formats are supported:
- png
- jpg
python mapnik-render.py -f fonts -s style.xml -l 0 0 -z 1 -d 1024 600 -o output.pdf
The mapnik-render.py script also supports the following vector formats:
- svg
- ps
A note about fonts: the fonts you use must support embedding and editable documents. Else they will look fine in Acrobat Reader but will appear as [] boxes in Illustrator and other design software.
Each vector format has it's own peculiarities. Symbols are especially difficult as Mapnik / Cairo seems to mask those instead of placing single instances (they effectively turn into full screen pattern fills). Grab the invisible mask edges and delete them. Replace manually.