I found this problem when calculating array from rasters:
with rasterio.open(file) as ds:
arr3d=ds.read()
arr3d=np.ma.masked_where(arr3d==-32768,arr3d,False)
list=[]
for i in range(0,24):
tmean=arr3d[i,:,:].mean()
list.append(tmean)
I just wanted to get the list containing 24 mean values, but this code returned the list including each layer of arr3d, its mask layer and mean values.
len(list)=72
But when I tried arr3d[i,:,:].mean()
, just retruned a mean value without any array.
What is the differce between arr.mean()
and np.mean(arr)
?