1

I am trying to create a kml version of a map tile using gdal_translate on a geotiff with alpha layer (link here) as follows:

gdal_translate -of KMLSUPEROVERLAY input.tif output.kml

however, the resulting kml file has a black area where the alpha layer should be - see here for a link to all the input and output files (and subdirectories produced by the operation).

How can I produce a kml file without the black area (also how I could generate only a single standalone .kml file, rather than a .kml linking a bunch of subdirectories as in the zipfile linked)?

gdalinfo on the input geotiff:

Driver: GTiff/GeoTIFF
Files: input.tif
Size is 3822, 3837
Coordinate System is:
PROJCS["WGS 84 / Pseudo-Mercator",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Mercator_1SP"],
    PARAMETER["central_meridian",0],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    EXTENSION["PROJ4","+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 +wktext  +no_defs"],
    AUTHORITY["EPSG","3857"]]
Origin = (-13539823.138956749811769,4690722.589982722885907)
Pixel Size = (0.122995666356360,-0.122995666356360)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_DOCUMENTNAME=/mnt/dd/data/1417212380_DDSPIDER/tmp-0-0.tif
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
  TIFFTAG_XRESOLUTION=72
  TIFFTAG_YRESOLUTION=72
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (-13539823.139, 4690722.590) (121d37'49.08"W, 38d47' 0.99"N)
Lower Left  (-13539823.139, 4690250.656) (121d37'49.08"W, 38d46'49.09"N)
Upper Right (-13539353.050, 4690722.590) (121d37'33.88"W, 38d47' 0.99"N)
Lower Right (-13539353.050, 4690250.656) (121d37'33.88"W, 38d46'49.09"N)
Center      (-13539588.094, 4690486.623) (121d37'41.48"W, 38d46'55.04"N)
Band 1 Block=3822x1 Type=Byte, ColorInterp=Red
  Mask Flags: PER_DATASET ALPHA 
Band 2 Block=3822x1 Type=Byte, ColorInterp=Green
  Mask Flags: PER_DATASET ALPHA 
Band 3 Block=3822x1 Type=Byte, ColorInterp=Blue
  Mask Flags: PER_DATASET ALPHA 
Band 4 Block=3822x1 Type=Byte, ColorInterp=Alpha
1

1 Answer 1

4

The default output format for the tiles is jpeg and jpeg can't be made transparent. You must create tiles in png format. The GDAL KMLSUPEROVERLAY format is for some reason undocumented but with creation option "format=png" you should be able to create png tiles which support transparency. Even there is no documentation about the driver in the GDAL web site all the configuration options can be listed with the gdalinfo command gdalinfo --format KMLSUPEROVERLAY

The command for creating tiles in png format is thus

gdal_translate -of KMLSUPEROVERLAY input.tif output.kml -co format=png

When it comes to directory of tiles, that's how KML superoverlay is planned to work https://developers.google.com/kml/articles/raster.

1
  • Also found that it was easier (no directory of tiles, just the original tif) to just generate the simple .kml to directly load the input geotiff (only requires tile extents and a couple of headers / footers). Commented Dec 3, 2014 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.