Hi,
I have an NDVI Image which is stored as a one byte (8-bit) with a range of 0-255. The valid range of the data is 0-250, with 251 and 255 being quality flags. I wish to convert the images using the formula I was provided with [NDVI(real) = (NDVI- 125)/125] using the ImageMath function but when I run the below script it just produces a binary image. How would I produce the correct expression to remove values > 250 and then (image – 125)/125?
import os
import rsgislib
from rsgislib import imagecalc
from rsgislib.imagecalc import BandDefn
print("Converting NDVI range from 255 to -1-1")
# convert NDVI from 255 to -1 to 1
outputImage = 'ndvi_corrected.kea'
gdalformat = 'KEA'
datatype = rsgislib.TYPE_32UINT
expression = '(b1-125)/125'
imagecalc.imageMath('NDVI_20160101.kea', outputImage, expression, gdalformat, datatype)
Many Thanks,
Llion
On 30 Aug 2016, at 14:19, Llion Preston <llion....@gmail.com> wrote:
Hi Pete,
Brilliant, thought it would be something silly like that. Is there a way to alter the expression so that values > 250 are changed to NoData?
Thanks,
Llion
To post to this group, send email to rsgisli...@googlegroups.com.
Visit this group at https://groups.google.com/group/rsgislib-support.
For more options, visit https://groups.google.com/d/optout.