[gdal-dev] Problem with gdal2tiles and IE7

Jorge jorge.arevalo at gmail.com
Tue Mar 3 12:03:02 EST 2009


Hello everybody

I have problems with some tiles generated with gdal2tiles. Basically:
- I create 4-bands blank GTiff files (based on the extent of MIF files)
using this code.

shp = str(shapeFile)
tiff = str(tiffFile)
px = pxResolution
 
# Import vector shapefile
vector = ogr.GetDriverByName('Mapinfo File')
src_ds = vector.Open(shp)
src_lyr = src_ds.GetLayer( 0 )
src_extent = src_lyr.GetExtent() # Xmin Xmax Ymin Ymax (meters)

# Define raster properties
tiff_width = int((src_extent[1] - src_extent[0]) / px)
tiff_height = int((src_extent[3] - src_extent[2]) / px)

# Create new raster layer with 4 bands
raster = gdal.GetDriverByName('GTiff')
dst_ds = raster.Create( tiff, tiff_width, tiff_height, 4,gdal.GDT_Byte)

# Create raster GeoTransform based on upper left corner andpixel resolution
raster_transform = [src_extent[0], px, 0.0, src_extent[3],0.0, -px]
dst_ds.SetGeoTransform( raster_transform )

# Get projection of shapefile and assigned to raster
srs = osr.SpatialReference()
srs.ImportFromWkt(src_lyr.GetSpatialRef().__str__())
dst_ds.SetProjection( srs.ExportToWkt() )

# Create blank raster with fully opaque alpha band
zeros = numpy.zeros( (tiff_height, tiff_width), numpy.uint8 )
dst_ds.GetRasterBand(1).WriteArray( zeros )
dst_ds.GetRasterBand(2).WriteArray( zeros )
dst_ds.GetRasterBand(3).WriteArray( zeros )
opaque = numpy.zeros((tiff_height,tiff_width), numpy.uint8 )*255
dst_ds.GetRasterBand(4).WriteArray( opaque )


- Then, I rasterize the polygons of the MIF file to the GTiff file created using gdal_rasterize, based on my own colours and my own logic to apply them. 
I use the fourth band of each GTiff file as alpha channel, with the value 127 (50% transparency):

gdal_rasterize -b 1 -b 2 -b 3 -b 4 -burn <red1> -burn <green1> -burn <blue1> -burn 127 -where <sql_where1> -l <layer_name> <mif_file> <tiff_file>
gdal_rasterize -b 1 -b 2 -b 3 -b 4 -burn <red2> -burn <green2> -burn <blue2> -burn 127 -where <sql_where2> -l <layer_name> <mif_file> <tiff_file>
gdal_rasterize -b 1 -b 2 -b 3 -b 4 -burn <red3> -burn <green3> -burn <blue3> -burn 127 -where <sql_where3> -l <layer_name> <mif_file> <tiff_file>

I need 3 calls because I use 3 colours for my tiles. The "-where" option select different mif polygons in every call.

- After this, I create a VRT file using gdal_vrtmerge (I have a lot of GTiff files to be tiled): gdal_vrtmerge -o tiles.vrt <list_of_all_tiff>

- Finally, I apply gdal2tiles in that way: gdal2tiles -r near -s <the_epsg> -z <min_zoom> - <max_zoom> -v -w google tiles.vrt <tiles_dir>.

The generated tiles are properly shown on IE6 and Firefox, But IE7 shows an UGLY dark background and the borders of the thiles. I provide
screenshots of the map shown with ie6 (ok), firefox (ok) and ie7 (error).

http://www.nebulared.com/tmp_geo/ie6.png
http://www.nebulared.com/tmp_geo/ie7.png
http://www.nebulared.com/tmp_geo/firefox.png

Does anyone know what could be happening?

Thanks in advance

Regards
Jorge



More information about the gdal-dev mailing list