Raster calculator - complex conditional statement

4438
3
03-27-2014 06:48 AM
JonDra
by
New Contributor
Raster calculator - complex conditional statement

I need help creating a raster calculator syntax. I want to normalize precipitation values with the mean for specific altitude-classes:

I have two input rasters

1: reclassified dtm, with 1==0>dtm<200, 2==200>dtm<400, 3==400>dtm<600, ???10== if 1800>dtm<2000, 11== dtm>2000
2: precipitation.

I want to create a statement like

???if reclassified dtm=1, precipitation should be divided by the value for the average precipitation in 0-200m altitude,

if reclassified dtm=2, precipitation should be divided by the value for the average precipitation in 200-400m altitude,

???.
and

if reclassified dtm=11, precipitation should be devided by the value for the average precipitation in >2000m altitude.???

Is there any way this can be done in raster calculator?

(I have already done statistics to find average precipitation in the different altitudes and reclassified a dtm)
0 Kudos
3 Replies
JonDra
by
New Contributor
I had a tip about how to write an expression:
Con("dmt_reclass" == 1, "precipitation" / 270) & Con("dmt_reclass" ==  2, "precipitation" / 420) & .....
Where dmt_reclass is of course my reclassified dmt. 270 is the average precipitation in dmt_reclass 1 and so on.

But this won't work for me, my result is just a raster with a novalue it seems like.
I'm totally new to coding these, so I don't know what I'm doing wrong.
0 Kudos
curtvprice
MVP Esteemed Contributor
I want to normalize precipitation values with the mean for specific altitude-classes:

I have two input rasters

1: reclassified dtm, with 1==0>dtm<200, 2==200>dtm<400, 3==400>dtm<600, �?�10== if 1800>dtm<2000, 11== dtm>2000
2: precipitation.

I want to create a statement like

if reclassified dtm=1, precipitation should be divided by the value for the average precipitation in 0-200m altitude,
else if reclassified dtm=2, precipitation should be divided by the value for the average precipitation in 200-400m altitude,
...
if reclassified dtm=11, precipitation should be devided by the value for the average precipitation in >2000m altitude.


Is there any way this can be done in raster calculator?

(I have already done statistics to find average precipitation in the different altitudes and reclassified a dtm)


You could do this with nested Con statements, or the Pick tool, but I believe there is an easier way.

The Zonal Statistics tool replicates the mean for the zone for all cells in the zone -- so you can do this with the Raster Calculator tool:

float("precip") / ZonalStatistics("reclass_dtm", "VALUE",  "precip", "MEAN")
JonDra
by
New Contributor
It worked for me if I wrote it like this:
Con("dmt_reclass" == 1, "precipitation" / 270, Con("dmt_reclass" == 2, "precipitation" / 420, Con("dmt_reclass"==3, "precipitation" / 540)))
So a nested statement that is.


I haven't tried the zonal statistics tool with the raster calculator curtvprice, but I'm going to look into it!

Thanks for the help guys!
0 Kudos