2

I know this has been asked before but I have tried just about every post I've found and nothing seems to work. I have a GeoTIFF where areas outside the dataset have been set to nodata

When I open the GeoTIFF in QGIS the nodata areas are transparent

I tried:

gdal_translate -of KMLSUPEROVERLAY LVIS2_ABoVE2017_0706_R1803_075811.tif  alpha.kml

But that resulted in all my NoData areas showing up black enter image description here

Then I tried:

gdal_translate -of KMLSUPEROVERLAY -a_nodata 0 alpha.tif alpha.kml -co format=png

As I understand JPEG does not support transparent background so I should use PNG. But that resulted in no image at all (still zooms to the correct location)

The closest I could get was:

gdalwarp -srcnodata 0 -dstalpha LVIS2_ABoVE2017_0706_R1803_075811.tif LVIS_alpha.tif

Which did eliminate the black background in when I opened in ArcMap but resulted in a blank KMZ again when I tried gdal_translate

I also tried the -ot Byte thinking maybe its due to being Float32 but that didn't seem to work either

gdalinfo output:

Size is 2488, 2488
Coordinate System is:
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"]]
Origin = (211.588427999999965,64.714126000000007)
Pixel Size = (0.000100000000000,-0.000100000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (     211.588,      64.714) (211d35'18.34"E, 64d42'50.85"N)
Lower Left  (     211.588,      64.465) (211d35'18.34"E, 64d27'55.17"N)
Upper Right (     211.837,      64.714) (211d50'14.02"E, 64d42'50.85"N)
Lower Right (     211.837,      64.465) (211d50'14.02"E, 64d27'55.17"N)
Center      (     211.713,      64.590) (211d42'46.18"E, 64d35'23.01"N)
Band 1 Block=2488x1 Type=Float32, ColorInterp=Gray
  Min=130.450 Max=313.650
  Minimum=130.450, Maximum=313.650, Mean=162.552, StdDev=50.426
  Overviews: 1244x1244, 622x622, 311x311, 156x156
  Metadata:
    STATISTICS_MAXIMUM=313.64999389648
    STATISTICS_MEAN=162.55166902341
    STATISTICS_MINIMUM=130.44999694824
    STATISTICS_STDDEV=50.425973702069

What could the problem be?

UPDATE: I tried setting the NoData value as I read on some posts:

  Min=130.450 Max=313.650 
  Minimum=130.450, Maximum=313.650, Mean=162.552, StdDev=50.426
  NoData Value=0
  Metadata:
    STATISTICS_MAXIMUM=313.64999389648
    STATISTICS_MEAN=162.55166902341
    STATISTICS_MINIMUM=130.44999694824
    STATISTICS_STDDEV=50.425973702069

Also tried:

gdalbuildvrt $VRT $inFile -addalpha  
gdal_translate -scale -ot Byte -mask 2 $VRT $outTIFF

and I found that when I opened the bands individually in ArcMap, -addalpha is masking the entire image. If I just open band 1 then everything views fine and it scaled properly to 0-255.

EDIT2:

I tried:

gdal_translate $inFile $out -a_nodata 0
gdalbuildvrt $VRT $inFile -srcnodata 0
gdal_translate -scale -ot Byte $VRT $TIFF

and this appears to work. I opened the resulting tiff in ArcMap and it looked like this.

enter image description here

However when I do:

gdal_translate -of KMLSUPEROVERLAY $TIFF $KML

the resulting KML is blank. It has an extent but nothing else and the file size is only 1KB.

What could be causing this?

  • I created my GeoTIFF in python so I used an alpha shape to set all the nodata pixels to Nan. Haven't quite figured out how to create an alpha layer from that yet though – p0ps1c1e Aug 6 at 11:41
1

With some help from user2856s answer I figured it out. Like he said first I needed to scale down to 0-255 before converting to Byte.

Then the issue was I was not exporting the KML along with the tiles... silly mistake. I just put the kml in a folder with all the tiles.

Hopefully this answer helps someone else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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