Thanks Dane,

I got it working nicely, now I can get to work on the fun part.
I didn't quite understand the Mecator coordinates, when I tried (+init=epsg:4326) I got another blank.
but after some fiddling the code below worked nicely.

Strange but good for now.

Thanks again

Simon


Those coordinates are in long/lat but your map srs is Mercator. You need to pass Mercator coordinates. Or change you map srs to +init=epsg:4326 (a shorthand for long lat)

#!/usr/bin/python

import mapnik
import sys, os
import cairo

if __name__ == "__main__":
    try:
        mapfile = os.environ['MAPNIK_MAP_FILE']
    except KeyError:
        mapfile = "osm.xml"
        map_output = 'manchester_map2.svg'
    #---------------------------------------------------
    #  Change this to the bounding box you want
    ll = (-2.25575, 53.4859, -2.22755, 53.46748)
    #---------------------------------------------------

    imgx = 1000
    imgy = 1000

    m = mapnik.Map(imgx,imgy)
    mapnik.load_map(m,mapfile)
prj = mapnik.Projection("+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")
    c0 = prj.forward(mapnik.Coord(ll[0],ll[1]))
    c1 = prj.forward(mapnik.Coord(ll[2],ll[3]))
    bbox = mapnik.Envelope(c0.x,c0.y,c1.x,c1.y)
    m.zoom_to_box(bbox)

file = open(map_output, 'wb')
surface = cairo.SVGSurface(file.name, imgx, imgy)
mapnik.render(m, surface)
surface.finish()

_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to