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
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.
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?