[gdal-dev]
gdal_calc.py, calculating the mean value of masked arrays
christian yrrman
yrrman at gmail.com
Thu Sep 29 07:00:14 EDT 2011
Dear All,
I'm trying to use gdal_calc.py to solve the following problem:
I have a time series of NDVI data as 8bit tiff files with different
BadData pixels (>50 and <250; this is the same for all layers) from
which I would like to calculate the mean.
(i.e. the same pixel might not be valid in all members of the time
series, and accordingly: Only sum up valid values and divide by the
number of valid layers, not all).
There exists a numpy array function that does exactly this:
[0] ma.masked_outside(d, 0.1, 0.9).mean() # calculating the mean only
within the interval [0.1 - 0.9]
As far as I understand it, gdal_calc.py can also use numpy array
funtions for calculations, but I'm not sure how this should look like;
something like this:
Pseudo-code:
gdal_calc.py -A layer1.tif -B layer2.tif -C layer3.tif
--outfile=test.tif --calc="masked_outside((A,B,C), 50,250).mean" ?
Do you think this is possible? Thanks in advance, and help highly appreciated!
:-)
Greetings, Chris
[0] http://docs.scipy.org/doc/numpy/reference/maskedarray.generic.html#data-with-a-given-value-representing-missing-data
More information about the gdal-dev
mailing list