Select to view content in your preferred language

Raster calculator and Con statement

719
4
Jump to solution
03-15-2023 07:18 PM
JasmineSpring
New Contributor III

Hello 

I am having troubles building my expression in raster calculator

I am trying to work around not being able to use decimals in reclassification. I am multiplying multiple rasters, If the values is 1, Id like it to stay a 1 and all other values be divided by 100 before I multiply them. After mutliply the rasters I want to take the value from 1.

1 - (Con("Grid1" = 1 ,1 , "Grid1" /100 )* Con("Grid2 " = 1 ,1,"Grid2" /100))

Hope that makes sense

Thank you!!

Jasmine

0 Kudos
1 Solution

Accepted Solutions
Luke_Pinner
MVP Regular Contributor

Try explicitly using decimals

1.0 - (Con("Grid1" == 1, 1.0, "Grid1" / 100.0 ) * Con("Grid2 " == 1, 1.0, "Grid2" / 100.0))

Or possibly using the Float function:

1.0 - (Con("Grid1" == 1, 1.0, Float("Grid1") / 100.0 ) * Con("Grid2 " == 1, 1.0, Float("Grid2") / 100.0))

View solution in original post

4 Replies
Luke_Pinner
MVP Regular Contributor

The equals operator is "==" not "=".

So you should use:

1 - (Con("Grid1" == 1, 1 , "Grid1" / 100 ) * Con("Grid2 " == 1, 1, "Grid2" / 100))

A worked example assuming Grid1 == 1 and Grid2 == 2

expression evaluates to: 1 - 1 * 0.02 

output: 0.98

JasmineSpring
New Contributor III

Thank you for your help!

Unfortunately it didnt work, it just gave one value in the resulting raster

yes that is the resulting equation im after !

for example 

1 - (1*0.2*0.8*1*0.4) = 0.936

but what I have is integers

1- (1 *20 * 80 * 1 *40)

so if the value is a 1, Id like to keep it as a 1 and if its higher than 1 Id like to divide it by 100 to make it a decimal.

Thank you!

0 Kudos
Luke_Pinner
MVP Regular Contributor

Try explicitly using decimals

1.0 - (Con("Grid1" == 1, 1.0, "Grid1" / 100.0 ) * Con("Grid2 " == 1, 1.0, "Grid2" / 100.0))

Or possibly using the Float function:

1.0 - (Con("Grid1" == 1, 1.0, Float("Grid1") / 100.0 ) * Con("Grid2 " == 1, 1.0, Float("Grid2") / 100.0))

JasmineSpring
New Contributor III

worked perfectly!! thank you so much

0 Kudos