On Sun, 2009-06-21 at 11:28 -0700, Andrew Ayre wrote:
> I've given up on trying to compile pgsql2sqlite for now and instead made
> some progress on using a georeferenced layer using Gdal. However it
> seems that Mapnik is clipping the image even though I have set the map
> size to the size of the bitmap and used the bitmap envelope.
>
> Here are my input files:
>
> http://files.britishideas.com/public/mapping/osmgeoref.png
> http://files.britishideas.com/public/mapping/osmgeoref.pgw
>
> I run this script:
>
> -------------------------------------------
> from mapnik import *
> m = Map(800,391,'+proj=latlong +datum=WGS84')
> m.background = Color('red')
> s = Style()
> r=Rule()
> r.symbols.append(RasterSymbolizer())
> s.rules.append(r)
> m.append_style('My Style',s)
> lyr = Layer('world')
> lyr.datasource = Gdal(file='osmgeoref.png')
> lyr.styles.append('My Style')
> m.layers.append(lyr)
> m.zoom_to_box(lyr.envelope())
> render_to_file(m, 'demo.png')
> save_map(m, 'map.xml')
> -------------------------------------------
>
> And here is the output with the top and bottom of the input PNG missing:
>
> http://files.britishideas.com/public/mapping/demo.png
>
> For completeness here is the output XML file:
>
> http://files.britishideas.com/public/mapping/map.xml
>
> I used red as a background colour to highlight the issue. Any ideas what
> I am doing wrong? I'm sure I'm overlooking something silly.
I can not explain it particularly clearly, but I believe the problem is
that the original image was not created in latlong projection, hence the
800x361 pixels are not square:
$ gdalinfo osmgeoref.png
Driver: PNG/Portable Network Graphics
Files: osmgeoref.png
Size is 800, 391
Coordinate System is `'
Origin = (-110.812896694075803,32.220948081346208)
Pixel Size = (0.000037724479586,-0.000031870889024)
Notice how the pixel sizes are different in the two dimensions. If you
adjust the output bitmap to fit this ratio then you get:
800 * 0.000037724479586 / 0.000031870889024 = 947
Then resize the map to this dimension:
m = Map(947,391,'+proj=latlong +datum=WGS84')
The final output then looks like the original with no clipping.
Jon
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users