GeoTIFF Transparency
I have spent way too much time messing with this, and certainly too many CPU cycles processing only to get the wrong output. The problem…
“Two irregular shaped geotiffs that you need to merge into one and not have any stupid gaps”
My first attempts resulted in things like…
Not the desired output, but the fix was easy really, first fix the nodata value with
gdal_translate -a_nodata 0 \ -of GTiff \ file1.tif \ file1_nodata0.tif
gdal_translate -a_nodata 0 \ -of GTiff \ file2.tif \ file2_nodata0.tif
Then merge the two
gdal_merge.py -n 0 \ -a_nodata 0 \ file1_nodata0.tif file2_nodata0.tif \ -o merged_file
That results in a nicely merged GeoTIFF
2 COMMENTS
So I thought about this last night and it occured to me that maybe I don’t need to set the nodata to 0, actually by doing so I think I am essencially saying that black is no data, so transparent, which might be a bit of an issue for black things in the image so why not keep it at -1000. So now I am trying the same thing but using the command:
gdal_merge.py -n -1000 -a_nodata -1000 file1.tif file2.tif -o merged.tif
Well that did not work! So will keep nodata to 0!