1

When I 'm calculating this expression:

("%Soil organic carbon (t/ha)%" / (10000 * "%Soil depth (m)%" * (Float("%Bulk density (kg/m3)%") / 1000))) * 100

Where:

"%Soil organic carbon (t/ha)%" and "%Bulk density (kg/m3)%" are raster layers

and

"%Soil depth (m)%" is any value or calculator expression with input values: 0.05, 0.15, 0.30, etc.

enter image description here

I 'm geting this error:

ERROR 000539: Error running expression: rcexec() Traceback (most recent call last): File "", line 1, in File "", line 5, in rcexec File "c:\program files\arcgis\desktop10.5\arcpy\arcpy\sa\Functions.py", line 4483, in Times in_raster_or_constant2) File "c:\program files\arcgis\desktop10.5\arcpy\arcpy\sa\Utils.py", line 53, in swapper result = wrapper(*args, **kwargs) File "c:\program files\arcgis\desktop10.5\arcpy\arcpy\sa\Functions.py", line 4480, in Wrapper ["Times", in_raster_or_constant1, in_raster_or_constant2]) RuntimeError: ERROR 000732: Input Raster: Dataset 0.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.050.05 does not exist or is not supported

Failed to execute (Raster Calculator).

Оn the contrary, when I write down "Soil depth" by hand like this, everything is ok

enter image description here

How to fix this problem?

  • Have you checked if all rasters are in the same projection? Are they all the same data / raster type (float...unsigned 8 bit...etc)? – Keagan Allan Dec 15 '19 at 22:00
2

Don't use quote symbols around numeric variables. Using quotes includes the values as strings!

So, where you have 10000 * "%Soil Depth (m)%", this is equivalent to saying 10000 * "0.05". NOT 10000 * 0.05.

When you multiply a string by 10,000, you get that string concatenated to itself, 10,000 times! Something like:

0.050.050.050.050.050.050.050.050.050.050.050.050.050.050.05... etc. Which is what you see in your error message.

So change it to: 10000 * %Soil Depth (m)% (ie, without the double quotes). The whole calculation then would be:

("%Soil organic carbon (t/ha)%" / (10000 * %Soil depth (m)% * (Float("%Bulk density (kg/m3)%") / 1000))) * 100

See also the Raster Calculator documentation which states:

Long, double, or Boolean-type variables will be enclosed in percent symbols (%%). They do not need to be in quotes.

Example: %scale_factor%

|improve this answer|||||
  • Earlier, I was little confused after removing double quotes before and after percent symbols in raster calculator, because it showed me an ERROR 000989 Python syntax error: Parsing error SyntaxError: invalid syntax (line 1). However, everything worked just fine with that. – Boban_Miletich Dec 16 '19 at 17:38

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.