ArcGIS pitfall of the day: exponentiation with rasters and tables

In raster calculator use the double asterisk ** for exponentiation. With vectors, in field calculator use the caret ^ for exponentiation.

Now in more detail:

Let’s say you have an input raster [raster1]. Now you want to calculate ‘[raster2] = [raster1] to the power of 5’.

You do this in raster calculator with this expression:

[raster2] = [raster1] ** 5

In other applications and in programming you might have used the caret symbol ^ as exponentiation operator, like this:

[raster2] = [raster1] ^ 5

In raster calculator this is wrong – the caret symbol does not stand for exponentiation, but for the Boolean XOR operator. See the ArcGIS Help for details.

Now, for tables: You want to calculate ‘[field2] = [field1] to the power of 5’ in field calculator, and if you look it up in ArcGIS Help it says to use a double asterisk expression, same as for rasters:

[field2] = [field1] ** 5

However, for me this expression results in an error 999999. I then try the expression with a caret:

[field2] = [field1] ^ 5

And voila, this actually results in exponentiation of [field1] as intended.

I verified the above on ArcGIS 10.2.1.

Conclusion: In many applications and programming languages the caret character stands for exponentiation, but this is actually not a standard. So if you use the caret as an operator always look up what it stands for in that particular application.

Finally, a brain teaser: In raster calculator the caret is a Boolean XOR. So what does the expression ‘[raster1] ^ 5’ evaluate to?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s