(1) INRAE, (2) La TeleScop
Firenze, FOSS4G - 25 Aug. 2022
Goal: labeling the bare soils
Goal: labeling the bare soils
import pyotb
# Pansharpening
pxs = pyotb.BundleToPerfectSensor(inp='pan.vrt', inxs='xs.tif')
# Computing NDVI
ndvi = (pxs[:, :, -1] - pxs[:, :, 0]) / (pxs[:, :, -1] + pxs[:, :, 0])
# Computing a boolean raster to identify pixels without vegetation
bare_soils = (ndvi < 0.3)
# Creating a boolean cloud mask from the GML vector
cloud_mask = pyotb.Rasterization('cloud_mask.GML', im=bare_soils)
# Masking clouds (i.e. assigning to 0) on the result
bare_soils_masked = pyotb.where(cloud_mask == 1, 0, bare_soils)
bare_soils_masked.write('bare_soils.tif', pixel_type='uint8')
Code sample