4

GDAL

I have installed gdal in the following way:
conda create -c conda-forge -n mygdalenv gdal python=3.6
on Ubuntu 18.04.2 LTS.

Input GeoTIFF

I have a GeoTiff image. The result of gdalinfo input.tif is:

Driver: GTiff/GeoTIFF
Files: input.tif
Size is 10455, 13254
Coordinate System is:
GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["geodetic latitude (Lat)",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["geodetic longitude (Lon)",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    USAGE[
        SCOPE["unknown"],
        AREA["World"],
        BBOX[-90,-180,90,180]],
    ID["EPSG",4326]]
Data axis to CRS axis mapping: 2,1
Origin = (41.462915653613621,37.384259792199842)
Pixel Size = (0.000125314982135,-0.000125314982135)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_IMAGEDESCRIPTION=input
  TIFFTAG_RESOLUTIONUNIT=1 (unitless)
  TIFFTAG_XRESOLUTION=1
  TIFFTAG_YRESOLUTION=1
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (  41.4629157,  37.3842598) ( 41d27'46.50"E, 37d23' 3.34"N)
Lower Left  (  41.4629157,  35.7233350) ( 41d27'46.50"E, 35d43'24.01"N)
Upper Right (  42.7730838,  37.3842598) ( 42d46'23.10"E, 37d23' 3.34"N)
Lower Right (  42.7730838,  35.7233350) ( 42d46'23.10"E, 35d43'24.01"N)
Center      (  42.1179997,  36.5537974) ( 42d 7' 4.80"E, 36d33'13.67"N)
Band 1 Block=10455x13254 Type=Float32, ColorInterp=Gray

Conversion to KMZ

I then try to convert it into a KMZ, in the following way:
gdal_translate -of KMLSUPEROVERLAY input.tif output.kmz

Issue

The conversion is super fast (too fast I would say) and always results in a 4.5MB file, while the input is 500MB.
When I visualize the KMZ file in Google Earth Pro (simple drag and drop), the image is correctly located, but is just a black rectangle.

Any help on what step I am doing wrong/forgetting?

2
  • 1
    Your source image seems to be of Type=Float32. Try with gdal_translate -scale -of KMLSUPEROVERLAY input.tif output.kmz but I agree that the small file size is suspicious.
    – user30184
    Oct 17, 2019 at 9:51
  • 1
    Thanks @user30184! It solved my issue. I just need to figure out why -a_nodata 0 doesn't remove black borders.
    – Tom
    Oct 17, 2019 at 10:36

1 Answer 1

6

The answer is in the comments, namely adding -scale.

The full command is:
gdal_translate -scale -of KMLSUPEROVERLAY input.tif output.kmz

Your Answer

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

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