[OSM-dev] Specifying area and zoom in Mapnik
Artem Pavlenko
artem at mapnik.org
Fri Mar 23 16:13:03 GMT 2007
On 23 Mar 2007, at 15:52, Keith Sharp wrote:
> Hello,
>
> 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:
>
>
> #!/usr/bin/python
>
> 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
projection
p = Projection("+proj=merc +datum=WGS84")
c0 = p.forward(Coord(-50,-50))
c1 = p.forward(Coord(50,50))
bbox = Envelope(c0,c1)
HTH
Cheers,
Artem
> m.zoom_to_box(bbox)
> 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!
>
> Keith.
>
> 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
> http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/dev
>
Artem Pavlenko
http://mapnik.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20070323/62190316/attachment.html>
More information about the dev
mailing list