3 # Generates a single large PNG image for a UK bounding box
4 # Tweak the lat/lon bounding box (ll) and image dimensions
5 # to get an image of arbitrary size.
7 # To use this script you must first have installed mapnik
8 # and imported a planet file into a Postgres DB using
11 # Note that mapnik renders data differently depending on
12 # the size of image. More detail appears as the image size
13 # increases but note that the text is rendered at a constant
14 # pixel size so will appear smaller on a large image.
19 if __name__
== "__main__":
21 mapfile
= os
.environ
['MAPNIK_MAP_FILE']
26 #---------------------------------------------------
27 # Change this to the bounding box you want
29 #ll = (-6.5, 49.5, 2.1, 59)
30 ll
= (24.32615, 44.10178, 24.37145, 44.1322) # Caracal
31 ll
= (24.30, 44.08, 24.38, 44.14) # Caracal
32 #---------------------------------------------------
40 prj
= 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 +nadgrids=@null +no_defs +over")
41 c0
= prj
.forward(Coord(ll
[0],ll
[1]))
42 c1
= prj
.forward(Coord(ll
[2],ll
[3]))
43 bbox
= Envelope(c0
.x
,c0
.y
,c1
.x
,c1
.y
)
47 view
= im
.view(0,0,imgx
,imgy
) # x,y,width,height
48 view
.save(map_uri
,'png')