Configuration Files Mapnik

Mapnik Python Script for Start-up and Processing

 * 1) !/usr/bin/env python

from mapnik import * mapfile = "population.xml" m = Map(1400, 600) load_map(m, mapfile) bbox = Envelope(Coord(-180.0, -75.0), Coord(180.0, 90.0)) m.zoom_to_box(bbox) render_to_file(m, 'world_population.png', 'png')

Mapnik XML Configuration File
 <!DOCTYPE Map>

 

 [POP2005] = 0   #ffffcc   black .1  </Rule> <Rule> [POP2005] &gt; 0 and [POP2005] &lt; 15000</Filter>  <CssParameter name="fill">#c7e9b4</CssParameter> </PolygonSymbolizer>  <CssParameter name="stroke">black</CssParameter> <CssParameter name="stroke-width">.1</CssParameter> </LineSymbolizer> </Rule> <Rule> [POP2005] &gt;= 15000 and [POP2005] &lt; 255000</Filter>  <CssParameter name="fill">#7fcdbb</CssParameter> </PolygonSymbolizer> </Rule> <Rule> [POP2005] &gt;= 255000 and [POP2005] &lt; 1300000</Filter>  <CssParameter name="fill">#1d91c0</CssParameter> </PolygonSymbolizer> </Rule> <Rule> [POP2005] &gt;= 1300000 and [POP2005] &lt; 4320000</Filter>  <CssParameter name="fill">#41b6c3</CssParameter> </PolygonSymbolizer> </Rule> <Rule> [POP2005] &gt;= 4320000 and [POP2005] &lt; 9450000</Filter>  <CssParameter name="fill">#225ea8</CssParameter> </PolygonSymbolizer> </Rule> <Rule> [POP2005] &gt;= 9450000 and [POP2005] &lt; 25650000</Filter>  <CssParameter name="fill">#225ea8</CssParameter> </PolygonSymbolizer> </Rule> <Rule> [POP2005] &gt;= 25650000 and [POP2005] &lt; 1134000000</Filter>  <CssParameter name="fill">#122F7F</CssParameter> </PolygonSymbolizer> </Rule> <Rule> <ElseFilter/>  <CssParameter name="fill">darkred</CssParameter> </PolygonSymbolizer> <LineSymbolizer> <CssParameter name="stroke">black</CssParameter> <CssParameter name="stroke-width">.7</CssParameter> </LineSymbolizer> </Rule> </Style> <Style name="countries_label"> <Rule> <Filter>[POP2005] &gt;= 4320000 and [POP2005] &lt; 9450000</Filter> <TextSymbolizer name="NAME" face_name="DejaVu Sans Bold" size="7" fill="black" halo_fill= "#DFDBE3" halo_radius="1" wrap_width="20" spacing="5" allow_overlap="false" avoid_edges="false" min_distance="10"/> </Rule> <Rule> <Filter>[POP2005] &gt;= 9450000 and [POP2005] &lt; 25650000</Filter> <TextSymbolizer name="NAME" face_name="DejaVu Sans Book" size="9" fill="black" halo_fill= "#DFDBE3" halo_radius="1" wrap_width="20" spacing="5" allow_overlap="false" avoid_edges="false" min_distance="10"/> </Rule> <Rule> <Filter>[POP2005] &gt;= 25650000 and [POP2005] &lt; 1134000000</Filter> <TextSymbolizer name="NAME" face_name="DejaVu Sans Book" size="12" fill="white" halo_fill= "#2E2F39" halo_radius="1" wrap_width="20" spacing="5" allow_overlap="false" avoid_edges="true" min_distance="10"/> </Rule> <Rule> <Filter>[POP2005] &gt;= 1134000000</Filter> <TextSymbolizer name="NAME" face_name="DejaVu Sans Book" size="15" fill="white" halo_fill= "black" halo_radius="1" wrap_width="20" spacing="5" allow_overlap="true" avoid_edges="true" min_distance="10"/> </Rule> </Style> <Layer name="countries" status="on"> <StyleName>population</StyleName> <StyleName>countries_label</StyleName> <Datasource> <Parameter name="type">shape</Parameter> <Parameter name="file">path/to/your/unzipped/TM_WORLD_BORDERS_SIMPL-0.2/TM_WORLD_BORDERS_SIMPL-0.2</Parameter> </Datasource> </Layer>

</Map>