# Scale raster in ArcGIS using raster calculator

I have a raster with values ranging from 0 to 8991130624. This raster is actually the result of a cost distance analysis.

I want to scale the raster to range from 0 to 1 and take the inverse? so that a cell with the highest cost/value (e.g. 8991130624) will now have a value of 0 while a cell with the lowest cost/value (e.g. 0) will now have a value of 1.

I am using raster calculator with the following expression:

1-(x/8991130624)

where I add x to the expression by clicking on the raster from the list of available rasters when using the tool

This is not working and producing an error: "ERROR 000539: Error running expression; rcexec() :ERROR 999998:Unexpected Error."

Can someone tell me what I'm doing wrong?

-

Also it should be 1.0 - (x / 8991130624) otherwise you may end up with just 1's and 0's

To edit, if the values are cast as integers, you will end up with 0 or 1. At least one value must be a float, hence, 1.0 will ensure that the output is a floating point value between 0 and 1.

-
This is a good point, Dan: a solution that does not force floating point arithmetic will produce mysterious results. But to avoid integer division it does not suffice to use `1.0` instead of `1`, because it's too late to change the result of `x/8991130624`. It's clearer and more reliable to typecast such solutions explicitly, as in `1.0 - (float(x) / 8991130624.)`. The decimal point after `8991130624.` prevents ArcGIS from trying to store this number as an integer, where it will overflow 32-bit storage. (I suspect that may be the cause of the error reported by the O.P.) – whuber Jul 19 '13 at 13:36

Make sure you have spaces on either side of the mathematical operators:

``````1 - (x / 8991130624)
``````
-
Thanks! I'll check this out! – Julie Apr 15 '13 at 23:52