populateStats error in nodata values

34 views
Skip to first unread message

Carlos Leandro Cordeiro

unread,
Feb 7, 2017, 10:17:21 AM2/7/17
to RSGISLib Support
Hi everyone, 
I'm trying to apply the populatestats in my segmented image, however it's considering the -9999 and -32768 values as real values and not NoData. 
I tried change to Nodata using "gdalwarp -dstnodata -9999 input.tif output.tif" but it didn't work. 
Other values like 3.4028e38 or -1.7e308 is ok in statistic calculation.
Is there any command I can put in the script to consider these values as nodata?
Thanks

Daniel Clewley

unread,
Feb 7, 2017, 3:25:11 PM2/7/17
to Carlos Leandro Cordeiro, RSGISLib Support
Hi Carlos,

Currently the populateStats command only accepts 0 as a no data value so you will need to change the no-data values from -9999 to 0, you can do this using the imagemath command in RSGISLib.

Thanks,

Dan

--
You received this message because you are subscribed to the Google Groups "RSGISLib Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-suppo...@googlegroups.com.
To post to this group, send email to rsgislib...@googlegroups.com.
Visit this group at https://groups.google.com/group/rsgislib-support.
For more options, visit https://groups.google.com/d/optout.

Carlos Leandro Cordeiro

unread,
Feb 7, 2017, 4:02:50 PM2/7/17
to RSGISLib Support, carlosl...@gmail.com
Thanks Dan,

I found a problem in the expression. 
I searched how would be to change -9999 to 0, but I think I made a mistake. 
Sorry, but I'm new to python and this expression is a challenge to me.

import rsgislib
from rsgislib import imagecalc
outputImage = 'slope.tif'
gdalformat = 'GTiff'
datatype = rsgislib.TYPE_32FLOAT
expression = 'b1==-9999:0'
imagecalc.imageMath("slope_MA.tif", outputImage, expression, gdalformat, datatype)


Thanks

Nathan Thomas

unread,
Feb 7, 2017, 4:31:25 PM2/7/17
to RSGISLib Support
Try, b1==-9999?0:b1. This is an if (?) else (:) statement that says, if b1 is -9999 then give it a value of 0, else keep the value the same.

Nathan

Nathan Thomas

unread,
Feb 7, 2017, 4:31:34 PM2/7/17
to RSGISLib Support

Carlos Leandro Cordeiro

unread,
Feb 15, 2017, 5:40:07 AM2/15/17
to RSGISLib Support
Hi Nathan and Dan,
It worked well.
Thanks
Reply all
Reply to author
Forward
0 new messages