1 | #!/usr/bin/env python3
|
---|
2 | import sys
|
---|
3 | from os import path
|
---|
4 | import mapnik
|
---|
5 | m = mapnik.Map(600,300)
|
---|
6 | m.background = mapnik.Color('steelblue')
|
---|
7 | s = mapnik.Style()
|
---|
8 | r = mapnik.Rule()
|
---|
9 | polygon_symbolizer = mapnik.PolygonSymbolizer()
|
---|
10 | polygon_symbolizer.fill = mapnik.Color('#f2eff9')
|
---|
11 | r.symbols.append(polygon_symbolizer)
|
---|
12 |
|
---|
13 | line_symbolizer = mapnik.LineSymbolizer()
|
---|
14 | line_symbolizer.stroke = mapnik.Color('rgb(50%,50%,50%)')
|
---|
15 | line_symbolizer.stroke_width = 0.1
|
---|
16 |
|
---|
17 | r.symbols.append(line_symbolizer)
|
---|
18 | s.rules.append(r)
|
---|
19 | m.append_style('My Style',s)
|
---|
20 | ds = mapnik.Shapefile(file='/home/user/data/natural_earth2/ne_10m_admin_0_countries.shp')
|
---|
21 | layer = mapnik.Layer('world')
|
---|
22 | layer.datasource = ds
|
---|
23 | layer.styles.append('My Style')
|
---|
24 | m.layers.append(layer)
|
---|
25 | m.zoom_all()
|
---|
26 | mapnik.render_to_file(m,'world.png', 'png')
|
---|
27 | #
|
---|
28 | print ("rendered image to world.png")
|
---|
29 |
|
---|