I would like to check if my set of NDVI images with min/max values from -1 +1 is good for at least 80%.
I took my cue from this other topic: here. Considering that the nodata is -32768
But the values I get on multiple images are all the same.
with rasterio.open(NDVI[0], 'r') as src:
meta = src.meta.copy()
meta.update({"nodata":-32768})
data = src.read(1)
arr=data[data>-1.0]
pct_valid = 100 * (arr != meta['nodata']).sum() / (meta['width'] * meta['height'])
print('%.4f'%pct_valid)
OUTPUT:
-6.87526
How should I interpret it for my image?
To select only those images that are 80% good instead?
if pct_valid > 80.0:
write(raster)