Hello everyone:

I'm newbie with mapnik, when I use the demo easymapnik example I confronted
some problems, most of time I get a blank map. I know it's the projection
problem and tried many ways others used, and the result is negative. So I
made a simple python file to render map and the result is the same, a blank
map.

My python file.

#!/usr/bin/python

import mapnik

mapnikfile = "test.xml"

proj = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0
+x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgri...@null +no_defs +over"

m = mapnik.Map(500,500)

ll=(-1.45,50.9,51,1.35)

mapnik.load_map(m,mapnikfile)

m.srs = proj

prj = mapnik.Projection(proj)

bbox = prj.forward(mapnik.Envelope(ll[0],ll[1],ll[2],ll[3]))
print bbox
#m.zoom_all()       #when I use zoom_all() instead of
zoom_to_box(bbox), I got the right map
m.zoom_to_box(bbox)

print m.envelope()

m.layers[0].srs=proj # I set the layer's srs and don't know how to
convert the envelope to merc form
print "map layers"
print m.layers[0].srs
print m.layers[0].envelope()
mapnik.render_to_file(m,"my.png")


~

I used the test.xml and test2.osm in the
http://trac.mapnik.org/browser/trunk/plugins/input/osm?rev=919

After check some properties , the layer's srs is "+proj=latlong
+datum=WGS84" and the map's srs is "+proj=merc +a=6378137 +b=6378137
+lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgri...@null
+no_defs +over".It seems like the reason why I just got blank map.

I thought I should let the layer's coordinate as map's.  So I try to set the
layer's srs to the same as map's, but I don't find how to convert layer's
envelope to the merc form.

Can anyone tell me how to convert the layer's envelope or point my mistake?

Thank you!


With nik2img.py, the result is good.

-- 
Matrix Bai
http://matrix.3p-blog.com
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to