Search code examples
bashrastergdal

make all values but one in large raster file 0


I have a large raster file downloaded from Earth Engine. I want to turn it to a boolean file, keeping only one value (13) and make all other values either NA or 0. The file is so large it crashes QGIS and ArcMap when I try to process it, is there a way to do this using GDAL or bash? The file is a tif file.


Solution

  • With R you can do

    library(raster)
    library(rgdal)
    r <- raster("input.tif")
    x <- calc(r, function(i){ i==13 }, filename="output.tif", datatype="INT1U")
    

    Or use raster::reclassify