Hello,

i once downloaded two huge TIF from the Nasa web server, they are called
land_shallow_topo_east.tif and land_shallow_topo_west.tif.

I'd like to use these files as background when rendering a map, so i tried in 
a modified version of OSM's generate_image.py to add a layer for the east
TIF.  I've also set the background in "osm.xml" to "transparent".

The TIF data are not rendered, though.  I have copied the python script that
i use for this at the end of this mail.

Can anybody tell me what is going wrong here?

Has anybody else used these files as background?

Is there a better way to use these TIFs as background?

Can anybody confirm / correct the projection data that i need to use for the
TIFs from the Nasa server?


Best regards,
Torsten.



#!/usr/bin/python

# source set-mapnik-environment


#<Map bgcolor="#b5d0d0" srs="+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">
#<Map bgcolor="transparent" srs="+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">

from mapnik import *
import sys, os

if __name__ == "__main__":
    mapfile = "osm_print.xml"
    map_uri = "image.png"

    tifdir = "/local/vid/earth"
    west = "land_shallow_topo_west.tif"
    east = "land_shallow_topo_east.tif"


#    ll = (4.5, 46, 16, 56) # Deutschland
    ll = (-180.0, -85.0511, 180.0, 85.0511) # Welt, maximum
#    ll = (-180.0, -50.0, 180.0, 60.0) # Welt, aspect ration 4:3

    z = 10
    imgx = 600 * z
    imgy = 300 * z

    m = Map(imgx, imgy)

    r_east = Raster(base = tifdir, file = east, lox = 0.0, loy = -85.0511, hix 
= 180.0, hiy = 85.0511)
    l_east = Layer('tif_east')
    l_east.datasource = r_east

    r_west = Raster(base = tifdir, file = west, lox = 0.0, loy = -85.0511, hix 
= 180.0, hiy = 85.0511)
    l_west = Layer('tif_west')
    l_west.datasource = r_west

    l_east.active = True
    print l_east

    m.layers.append(l_east)

    load_map(m, mapfile)

    for l in m.layers:
        print l.name

    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 +nadgri...@null +no_defs +over")
    c0 = prj.forward(Coord(ll[0], ll[1]))
    c1 = prj.forward(Coord(ll[2], ll[3]))
    bbox = Envelope(c0.x, c0.y, c1.x, c1.y)

    m.zoom_to_box(bbox)

    print "scale", m.scale(), 1.0 / m.scale()
    print "denom", m.scale_denominator()

    im = Image(imgx, imgy)
    render(m, im)
    view = im.view(0, 0, imgx, imgy)
    view.save(map_uri, 'png')

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

Reply via email to