Hi  Félix,

I had a quick look - 12567 x 33784 is quite big for an image but it
should work with something like > 2GB of RAM. How much memory
available to Python is OS specific. it might be possible to tweak not
sure.

I'm just thinking, why don't you use Mapnik to generate actual tiles.
This way you won't have memory issues, also, re-sampling is
sub-optimal when it comes to image quality.

Here is link to very simple Python script you can try as a starting point:
http://trac.openstreetmap.org/browser/applications/rendering/mapnik/generate_tiles.py

You can just replace load_map(m,..) with your script, comment out line 97:
# command = "convert  -colors 255 %s %s" % (tile_uri,tile_uri)
and change extent/projections.

re: disabling anti-aliasing - the short answer is no. But you can work
around 'border stitching' problem. First try adding LineSymbolizer to
dilate polygons slightly. In the past I had solved this issue by
implementing specialized 'compositing' renderer. I can try to dig some
code if you're interested. This would be a great feature to have, but
probably for 1.0.0.


HTH,

Best
Artem

> Hello,
>
> I'll try to describe my use case:
>
> We have some shapefiles wich we want to, as the final result, show on Google
> Maps. These shapefiles are made of thousands of polygons, each being of 250
> x 250 meters. These polygons have an integer feature associated, lets say
> from 0 to 200. If the feature is below "50", the polygon must be rendered in
> red. If betweeen "50 and 150", in yellow, and if above "150" in green.
>
> Our maximum visualization zoom level in Google Maps is 14, which gives a
> resolution of ~ 7.4 m/px at the location of interest. (each polygon is then
> ~ 34 px). The shapefile width is 93000 m and 250000 m height. With these
> data, we believe we need to render the shapefile to a file (PNG) of 12567 x
> 33784 px in size to keep the accuracy of the original shapefile.
>
> The code to render the png is:
>
> from mapnik import *
>
> m = Map(12567,33784,"+proj=latlong +datum=WGS84")
> s = Style()
>
> a_rule=Rule()
> a_rule.filter = Filter('[Value] > -87 and [Value] <= -78')
> a_rule.symbols.append(PolygonSymbolizer(Color('#FF0000')))
>
> b_rule=Rule()
> b_rule.filter = Filter('[Value] > -78 and [Value] <= -72')
> b_rule.symbols.append(PolygonSymbolizer(Color('#FFFF00')))
>
> c_rule=Rule()
> c_rule.filter = Filter('[Value] > -72')
> c_rule.symbols.append(PolygonSymbolizer(Color('#00FF00')))
>
> s.rules.append(a_rule)
> s.rules.append(b_rule)
> s.rules.append(c_rule)
>
> m.append_style('My Style',s)
> lyr = Layer('E')
> lyr.datasource = Shapefile(file='C:/shapefiles/E')
> lyr.styles.append('My Style')
> m.layers.append(lyr)
> m.zoom_to_box(lyr.envelope())
> render_to_file(m,'C:/shapefiles/E.png', 'png')
>
> With that file size (12567,33784), we get a memory error. Is it possible to
> increase the memory heap used by python in order to generate this file?
>
> If we reduce the file size (e.g. 8378, 22523), the file is rendered but due
> to some antialiasing effect the borders of the polygons are blurred. We
> attach a picture in which you can see this effect and another showing how we
> would like to see it, as shown in Mapinfo loading directly the shape file
> and with a thematic map.
>
> Is it possible to disable antialiasing using mapnik?
>
> Once we have the file generated, we want to generate tiles for Google Maps
> from it either using gdal2tiles or tilecache + mapnik. In the first case, we
> need the png file to be georreferenced. Is it possible from mapnik to
> generate a world file for the png according to the extents and bound of the
> source shapefile?
>
> We haven't explored yet the tilecache + mapnik approach. gdal2tiles provides
> an option to resample the source file in order to generate missing pixels
> for the desired zoom level, so we believe we can provide a tinier source
> file which we can generate with mapnik from the shapefile, and then resample
> to the desired zoom level without loosing accuracy. Is it possible to make
> something similar with mapnik + tilecache?
>
> Thanks in advance.
>
> --
> Félix
>
>
> _______________________________________________
> Mapnik-users mailing list
> [email protected]
> https://lists.berlios.de/mailman/listinfo/mapnik-users
>
>
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to