1

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')) r.symbols.append(polygon_symbolizer) [ 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') mmap.layers.append(layer) mmap.zoom_all() mapnik.render_to_file(mmap,'/foo/bar/bla.png', 'png') 

1 Answer 1

1

This sounds similar to the bug reported at https://github.com/mapnik/mapnik/issues/1118.

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')) r.symbols.append(polygon_symbolizer) line_symbolizer = mapnik.LineSymbolizer(mapnik.Color('rgb(50%,50%,50%)'),1.0) r.symbols.append(line_symbolizer) s.rules.append(r) m.append_style('My Style',s) # DOES NOT WORK with GEOS according to http://gis.stackexchange.com/questions/32441/mapnik-wkt-rendering-problem # 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,Name "%s","test" ''' % 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') m.layers.append(layer) m.zoom_all() mapnik.render_to_file(m,'world.png', 'png') print "rendered image to 'world.png'" 
1
  • Yes, using the csv route does work. Now I know why python and geos input plugins are still experimental. Commented Sep 6, 2012 at 12:55

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.