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 = 0.1 lineSymbolizer = mapnik.LineSymbolizer(stroke) rule.symbols.append(polySymbolizer) rule.symbols.append(lineSymbolizer) style.rules.append(rule) map.append_style("My Style", style) datasource = mapnik.Shapefile(file="TM_WORLD_BORDERS-0.3...