I have a raster A .tif layer and a raster B .tif layer. I want to identify all pixels in raster B that are < 2 and set those corresponding pixels in raster A to 0, given that these rasters pixel grids are aligned. I understand that QGIS has conditional functions I can use for this within raster calculator, but since I need to loop through many raster files, I will need to rely and python and gdal. Trying to work this out, I would think code would look something like:
Calc("A where B < 2, 0, A", A=raster_A.tif, B=raster_B.tif, outfile=new_raster)
Though I am quite confused about using the proper logic and syntax here. How can I accomplish this conditional raster calculation using python and gdal?