[OSM-dev] Specifying area and zoom in Mapnik

Keith Sharp kms at passback.co.uk
Fri Mar 23 15:52:05 GMT 2007


I've got Mapnik installed and rendering data from my PostGIS install of
the weekly planet.osm if I use the generate_tiles.py script from svn.  I
can modify the area and zoom level I want and it all works.

What I would like to do now is create a script where I can specify an
image size, and the area I want to render.  I am having difficulty
working out how to do this.  I got as far as:


from mapnik import *

mapfile = "/home/kms/src/osm/mapnik/osm/osm.xml"
m = Map(800, 800, "+proj=latlong +ellps=WGS84")
load_map(m, mapfile)
bbox = Envelope(Coord(-50.0, -50.0), Coord(50.0, 50.0))
render_to_file(m, 'map.png', 'png')

But this doesn't do what I expect.  My main question is how do I specify
the bbox as a pair of WGS84 kat/lon coordinates?

For example I'd like to render the entire UK as:

	-8.920, 48.900 to 2.250, 61.300

or the area around Glasgow West:

	-4.350, 55.860 to -4.290, 55.900

Any help would be appreciated!


PS. Regarding getting the tile rendering stuff up and running - I plan
on tidying my notes up and putting them on the Wiki.

More information about the dev mailing list