[Qgis-user] Raster Calculator - If statements

Carlos Cerdán sig.upagu at gmail.com
Fri Feb 21 13:40:49 PST 2014


Hi Jonathan:

Interesting puzzle. You can get what you wish if you use GRASS (r.mapcalc
and r.null). With QGIS I just got zero or null, but band by band:

ZERO : (band1 at 1<=145)*band1 at 1

NULL : ( ((band1 at 1<=145)*band1 at 1) / ((band1 at 1<=145)*band1 at 1) ) * band1 at 1

Explanation:

1. ZERO: When condition in parenthesis is true, it goes 1, if doesn't, 0.
After that, multiply by the same band, so result is 0 in cells that
original value was major than 145, and it's the same value as original in
other cells.

2. NULL: We have same prior value  divided by himself. In cells where we
got 0, now will get NULL, and the original value in other cells.

I used 145 according your example.

Good luck

Carlos



2014-02-21 8:37 GMT-05:00 Jonathan Moules <
jonathanmoules at warwickshire.gov.uk>:

> Hi List,
> I have a three band raster. I want to do the following with:
>
> If (Band1 > 150 AND Band2 > 150 AND Band3 > 150){
>>   Band1 = 255
>>   Band1 = 255
>>   Band1 = 255
>> }
>
>
> Basically set all band values to 255 when all band values are > than a
> value of 150. All other band values should remain unchanged.
>
> How do I do this? I've got as far as the below for the :
>
>>  ( "CR0569TEI_00008_modified at 1" > 145 AND "CR0569TEI_00008_modified at 2" >
>> 145 AND "CR0569TEI_00008_modified at 3" > 145 )
>
>
> But am unsure what's next. The tutorials I've found online assume I only
> want 1 or 0 as my results.
>
> Help welcome. :-)
> Thanks,
> Jonathan
>
> This transmission is intended for the named addressee(s) only and may
> contain sensitive or protectively marked material up to RESTRICTED and
> should be handled accordingly. Unless you are the named addressee (or
> authorised to receive it for the addressee) you may not copy or use it, or
> disclose it to anyone else. If you have received this transmission in error
> please notify the sender immediately. All email traffic sent to or from us,
> including without limitation all GCSX traffic, may be subject to recording
> and/or monitoring in accordance with relevant legislation.
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20140221/fe3b6750/attachment.html>


More information about the Qgis-user mailing list