Feature request #4476

Add a 2 cases if() command to Raster Calculator

Added by alobo - over 5 years ago. Updated about 2 months ago.

Status:Feedback
Priority:Normal
Assignee:-
Category:Rasters
Pull Request or Patch supplied:No Resolution:
Easy fix?:No

Description

An if() command with 2 cases output would be most useful:

if(condition, result1, result2)

where the output value is result1 if condition==T and result2 otherwise.

Agus

History

#1 Updated by alobo - over 5 years ago

  • Category set to Rasters
  • Target version set to Version 1.7.1
  • Operating System set to all

#2 Updated by Tim Sutton over 5 years ago

  • Target version changed from Version 1.7.1 to Version 1.7.2

#3 Updated by Giovanni Manghi over 5 years ago

  • Target version changed from Version 1.7.2 to Version 1.7.3

#4 Updated by Giovanni Manghi over 5 years ago

  • Target version changed from Version 1.7.3 to Version 1.7.4

#5 Updated by Giovanni Manghi about 5 years ago

  • Target version changed from Version 1.7.4 to Version 2.0.0

#6 Updated by Pirmin Kalberer over 4 years ago

  • Target version changed from Version 2.0.0 to Future Release - Nice to have

#7 Updated by Médéric RIBREUX over 1 year ago

  • Status changed from Open to Feedback

Hello, bug triage...

the raster calculator can handle conditions but the expression is not so easy to understand:

("elevation@1" < 50) * 1 + ("elevation@1" >= 50) * 2

will make cells with a value less than 50 have a value of 1 and cells with a value greater than or equal to 50 have a value of 2.

Was your feature request about a way to have conditions in the raster calculator or about the syntax of the condition ?

#8 Updated by alobo - over 1 year ago

Well, that syntax is really odd, I had not even thought on it.
I guess that
if(condition, result1, result2)
would be a lot more transparent and easier to remember

#9 Updated by Giovanni Manghi about 2 months ago

  • Easy fix? set to No

Also available in: Atom PDF