I want to do the following: I have two data raster sets with different units and values. One results from measured metric data, the other from modelled grid values. What I want to compare is simply whether the data sets differ in where they show positive and negative values.

So - all negative data on both sets should be "-1", all data between -0.001 and 0.001 should be "0", and all positive values simply "1".

Do you have an idea how to do this best on ArcGIS 10? I suspect raster calculator...?


Your suspicion is a good one. There are two issues to address: what calculation will achieve the desired result and how to do it. The "how" is answered by a large, flexible array of choices, including the Raster Calculator, as well as the command line and Python scripting. Which you use depends on many contextual details not mentioned so far, so let's skip to the "what."

A good starting point for figuring out the "what" of raster calculations is the Spatial Analyst help system. Once you are familiar with its organization--which is partly in terms of the purpose and partly in terms of the nature of the calculation--you will find your choices are considerably narrowed. Here, you would look first at the math toolset, the reclass toolset, and possibly the local toolset. As in many situations, you won't find exactly what you need, but you will find the ingredients of a solution--usually of many solutions.

(What you need would be well served with a signum function, but it appears this basic tool has been omitted from SA.)

Many people would be satisfied with a reclass command or some multiple invocation of con, either of which would serve them well. However, I find that many forms of reclassification can be expressed efficiently and elegantly with mathematical formulas, so I will offer one here. It relies on the convention that Boolean "false" values are represented as zeros and "true" values as ones. So, for a hypothetical raster named "grid", consider the effect of this expression:

("grid" > 0.001) - ("grid" < -0.001)

The presence of two distinct numbers 0.001 and -0.001 causes us to consider three mutually exclusive, exhaustive cases:

  1. A value truly exceeds 0.001. In this case the first term, ("grid" > 0.001), is true (equal to 1) and the second is false (equal to 0). Their difference is 1, as intended.

  2. A value lies between -0.001 and 0.001, inclusive. In this case both terms are false (equal to 0), so their difference is 0, as intended.

  3. A value lies less than -0.001. The terms now equal 0 and 1, in that order. Their difference is -1, as intended.

The syntactic details depend on which version of Spatial Analyst is used: subtle differences in syntax processing exist between SA 9 and SA 10 and even within intermediate releases. Liberal use of parentheses is usually advisable and some care may be needed with the placement of white space and quotation marks. Experiment on small grids first until you are sure the syntax is right, check the results, and only then perform the operation for real.

  • 2
    Thanks Whuber for the extensive reply. The Raster Reclass Toolset brough the desired solution for now, but I am just printing off your answer to get a deeper understanding. Cheers! – Peter Jan 21 '13 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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