[Qgis-user] Raster Calculator - If statements

Jonathan Moules jonathanmoules at warwickshire.gov.uk
Mon Feb 24 06:30:57 PST 2014


Hi Carlos,
  Thanks for your thoughts. One observation - it appears that you are only
checking a single band at a time.
However I only want the values to be changed if ALL bands have a value of
>145. If only one or even two of the values are >145 then nothing should be
changed, it's only when all three are that I want it to be triggered.

That makes the problem even more tricky. :-)
Kind Regards,
Jonathan



On 21 February 2014 21:40, Carlos Cerdán <sig.upagu at gmail.com> wrote:

> 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
>>
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>

-- 
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20140224/80b16103/attachment.html>


More information about the Qgis-user mailing list