Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created May 23, 2013 16:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save springmeyer/5637596 to your computer and use it in GitHub Desktop.
Save springmeyer/5637596 to your computer and use it in GitHub Desktop.
Example of using the Mapnik python API to save a map constructed in python into an XML string or file
>>> import mapnik
>>> m = mapnik.Map(256,256)
>>> m.background = mapnik.Color('green')
>>> print mapnik.save_map_to_string(m)
<?xml version="1.0" encoding="utf-8"?>
<Map srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" background-color="rgb(0,128,0)"/>
>>> mapnik.save_map(m,'file.xml')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment