[OSM-dev] Specifying area and zoom in Mapnik
artem at mapnik.org
Fri Mar 23 16:13:03 GMT 2007
On 23 Mar 2007, at 15:52, Keith Sharp wrote:
> 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)
Here srs gets overwritten with one form mapfile. I suspect you have
mercator in osm.xml
> bbox = Envelope(Coord(-50.0, -50.0), Coord(50.0, 50.0))
Given the above is true you need to specify coordinates in Mercator
p = Projection("+proj=merc +datum=WGS84")
c0 = p.forward(Coord(-50,-50))
c1 = p.forward(Coord(50,50))
bbox = Envelope(c0,c1)
> render_to_file(m, 'map.png', 'png')
> But this doesn't do what I expect. My main question is how do I
> 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.
> dev mailing list
> dev at openstreetmap.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the dev