O'Reilly logo

Python Geospatial Development - Second Edition by Erik Westra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Map definition files

There is one final approach to using Mapnik that is worth examining. In addition to creating your symbolizers, rules, styles, and layers programmatically, Mapnik allows you to store all of this information using a map definition file. This is an XML-format file that defines the various Mapnik objects used to generate a map. For example, consider the following Python program to create a simple world map using the World Borders Dataset:

import mapnik map = mapnik.Map(800, 400) map.background = mapnik.Color("steelblue") style = mapnik.Style() rule = mapnik.Rule() polySymbolizer = mapnik.PolygonSymbolizer() polySymbolizer.fill = mapnik.Color("ghostwhite") stroke = mapnik.Stroke() stroke.color = mapnik.Color("gray") stroke.width ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required