Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a rendering problem with the mapnik GEOS plugin. I try to input a polygon WKT definition containing floats with around 16 digits. Mapnik however does not render these. When I decrease the number of digits to 5 it does work. Does anybody have a solution?

mmap.background = mapnik.Color('steelblue')
s = mapnik.Style() 
r = mapnik.Rule() 
polygon_symbolizer = mapnik.PolygonSymbolizer(mapnik.Color('#f2eff9'))
[ more style here ]
mmap.append_style('My Style',s) 

wkt_geom = 'POLYGON ((5.12345 51.6, 6.8 52.6, 7.8 51.6, 5.12345 51.6))' #DOES WORK
wkt_geom = 'POLYGON ((5.123456 51.6, 6.8 52.6, 7.8 51.6, 5.123456 51.6))' #DOES NOT WORK

layer = mapnik.Layer('wkt_layer_bla','+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.417,50.3319,465.552,-0.398957,0.343988,-1.8774,4.0725 +units=m +no_defs')
layer.datasource =  mapnik.Geos(wkt=wkt_geom)
layer.styles.append('My Style')
mapnik.render_to_file(mmap,'/foo/bar/bla.png', 'png')
share|improve this question

1 Answer 1

up vote 1 down vote accepted

This sounds similar to the bug reported at

It looks like a geos specific problem, because if I move to Mapnik 2.1 and use the CSV plugin (which accepts reading WKT strings using Mapnik's internal parser not GEOS) then things seem to work just fine. I get:

Using this code:

import mapnik

m = mapnik.Map(600,300,'+init=epsg:3857')
m.background = mapnik.Color('steelblue')
s = mapnik.Style()
r = mapnik.Rule()
polygon_symbolizer = mapnik.PolygonSymbolizer(mapnik.Color('#FF3366'))
line_symbolizer = mapnik.LineSymbolizer(mapnik.Color('rgb(50%,50%,50%)'),1.0)
m.append_style('My Style',s)
# DOES NOT WORK with GEOS according to
# DOES seem to work fine with Mapnik's CSV plugin
wkt_geom = 'POLYGON ((5.123456 51.6, 6.8 52.6, 7.8 51.6, 5.123456 51.6))' 
csv_string = '''
''' % wkt_geom
ds = mapnik.Datasource(**{"type":"csv","inline":csv_string})
layer = mapnik.Layer('world', '+init=epsg:3857')
layer.datasource = ds
layer.styles.append('My Style')
mapnik.render_to_file(m,'world.png', 'png')
print "rendered image to 'world.png'"
share|improve this answer
Yes, using the csv route does work. Now I know why python and geos input plugins are still experimental. – RickyA Sep 6 '12 at 12:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.