Reclassifying Landsat Cloud Masks

33 views
Skip to first unread message

André Beig

unread,
Mar 22, 2017, 1:57:48 PM3/22/17
to rsgislib...@googlegroups.com
Hello everyone, 

I'm trying to reclassify Landsat cloud masks in so that the values are 0 for areas with clouds, cloud shadows and snow and 1 for everything else, is there any rsgislib script that accomplishes that, I couldn't find any, but I'm new to the library, so maybe I was just looking in the wrong places.

thanks.

Pete Bunting [pfb]

unread,
Mar 22, 2017, 2:09:22 PM3/22/17
to André Beig, RSGISLib Support
Hello,

Try using the imageMath function and include if statements. The syntax for the maths expressions is muparser(http://beltoforion.de/article.php?a=muparser&hl=en&p=features&s=idDef1#idDef1)

The following expression is assuming your cloud, snow and cloud shadow pixels have values 1, 2 or 3. If any of those are true then set the output value as 0 otherwise 1.

import rsgislib
from rsgislib import imagecalc
imagecalc.imageMath(in.kea, out.kea, ‘(b1==1) || (b1==2) || (b1==3)?0:1', 'KEA', rsgislib.TYPE_8UINT)


If you have multiple input image bands then use rsgislib.imagecalc.bandMath.

Best wishes,

Pete
****************************************************
* Dr Pete Bunting
* Reader in Remote Sensing
* Earth Observation and Ecosystem Dynamics Group
* Department of Geography and Earth Sciences
* Aberystwyth University
* Aberystwyth
* Ceredigion
* SY23 3DB
* UK
*
* Ph: +44 (0) 1970 622615
* Mob: +44 (0) 7917 842743
* Email: p...@aber.ac.uk
* ORCID: http://orcid.org/0000-0002-7435-0148
****************************************************
"Please consider the environment before printing this email or any documents attached”

> On 22 Mar 2017, at 17:57, André Beig <beig...@gmail.com> wrote:
>
> I'm trying to reclassify Landsat cloud masks in so that the values are 0 for areas with clouds, cloud shadows and snow and 1 for everything else, is there any rsgislib script that accomplishes that, I couldn't find any.
>
> --
> 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.



--------------------------------------------------------------------
Un o’r 4 prifysgol uchaf yn y DU a’r orau yng Nghymru am fodlonrwydd myfyrwyr.
(Arolwg Cenedlaethol y Myfyrwyr 2016)
www.aber.ac.uk

Top 4 UK university and best in Wales for student satisfaction
(National Student Survey 2016)
www.aber.ac.uk

André Beig

unread,
Mar 22, 2017, 2:32:04 PM3/22/17
to RSGISLib Support
Thank you Pete, that worked just fine, I was trying to use imageMath but didn't know how to use the syntax correctly, so I assumed that I was supposed to use something else, now that's resolved! 


Reply all
Reply to author
Forward
0 new messages