1

This is in ArcGIS Pro. I will be performing a raster calculation to determine how much a given raster might change over time by multiplying the current raster by the percent projected change and then adding back to the current raster to give the 'new' raster

The problem is that the values for the raster need to be constrained to -17 (the worst case) to +17 and this approach could make me fall outside of those values. So, I know I need something that works sort of like an if then statement - if >17 then =17 and if < - 17 = -17 This is the step that is tripping me up. I have never been able to really come to grips with the CON statement and I think this may be what is needed here so could you provide any examples?

1

1 Answer 1

2

There's two different syntaxes for using Con:

Con("raster", true_value_or_raster, false_value_or_raster, "where_clause")

And

Con(in_conditional_raster, true_value_or_raster, {false_value_or_raster})

I always use the 2nd, it's easier to understand for me. You can generate the conditional raster on the fly in the function. i.e. Con("raster" > 1, etc...)

For your question, a nested Con function can be used:

Con("raster" > 17, 17, Con("raster" < -17, -17, "raster"))

What this does in pseudo code (for each pixel value):

if "raster" > 17   <-- in_conditional_raster
    output = 17    <-- true_value_or_raster
else               <--- false_value_or_raster using another Con
    if "raster" < -17   <-- in_conditional_raster
        output = -17    <-- true_value_or_raster
    else
        output = "raster"    <-- false_value_or_raster

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.