i am trying to render a map with Mapnik via Python. Therefore I first created a style file (as XML) and my code looks so far:
m = mapnik.Map(400, 400)
style = 'osm.xml'
mapnik.load_map(m, style)
box = mapnik.Box2d(347950, 5207105, 425404, 5316784)
m.zoom_to_box(box)
mapnik.render_to_file(m, 'map.png')
The problem is that the map shows the wrong part of the world. I think somewhere in the conversion is an error.
I tried the following values:
Lat/Lon: 47/7 ==> X/Y: 32T 347950mE 5207105mN
Lat/Lon: 48/8 ==> X/Y: 32U 425404mE 5316784mN
As I enter these lat/lon values on google maps it shows the mid east part of france southwest part of germany. Calculating the map with the calculated values i get the coast of france, especialle the city named "Port Vendres" in the lower left corner.
What am i doing wrong here?
The values in the database seem to bee in mercator form and the data was imported using osm2pgsql
with no special options.
Update:
I printed out m.srs
: +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over
and the scale_denominator()
: -8.92857142857
Update 2:
I read the documentation of osm2pgsql
and it says that it imports the data as spherical mercator by default.
So i assume that the values are stored in that format and the projection is correct.