I want to calculate the mean and standard deviation of a raster image. In QGIS zonal statistics, we can calculate it within a polygon or a vector. But I want to calculate for the whole image. In Python, I'm getting the same value for an image that I'm giving as input. How can I resolve this one...?
import numpy as np from osgeo import gdal g = gdal.Open('ndvi.tif') ndvi = g.ReadAsArray() ndvi = np.array(ndvi, dtype = float) M_ndvi = ndvi.mean() Std_ndvi = ndvi.std()
I tried this for different images, but the mean and standard deviation output is same for all.