I have 1,000 very large single-band rasters and many of them have nodata values. I want to take those nodata values and create a binary map to visualize all of the areas where I do not have data coverage.
Even after researching for quite awhile I don't really understand alpha bands/masks, where they exist, how to examine them. I thought I could just add an alpha band in GDAL but when I export the band I just get a raster full of 255s (checking with
# Adds alpha band gdalbuildvrt out_vrt src_dir/*.tif -b 1 -vrtnodata -9999 -addalpha # Deletes the first band, leaving just the alpha gdal_translate in_vrt out_tif -b 2
My next idea was to use
gdal_calc to create a binary tif where nodata=1 and data=0
# Both of these attempts left me with just a raster of zeroes # Attempt #1 gdal_calc.py -A src_tif.tif --A_band=1 --calc="(A<=-9999)" --outfile out_tif.tif --co compress=Deflate --type=Byte # Attempt #2 gdal_calc.py -A src_tif.tif --A_band=1 --calc="(A*0)" --NoDataValue=1 --outfile out_tif.tif --co compress=Deflate --type=Byte
Any tips? This seems like it should be so simple, it's driving me crazy