I have three rasters:
- Raster1: resolution 25x25, floating point. Value of "1" when it is true, value of -9999 when it is false (only this two values)
- Raster2: resolution 25x25, floating point. Only integer values from 194 to 1738
- Raster3: resolution 25x25, floating point. Decimal values are stored too, from -2544,81 to 941,66
All the rasters have the same CRS and are in TIFF format.
What I want to do is to create a fourth raster like this:
If Raster1 =1, then Raster2 (true statement), else Raster3 (false statement)
I tried this in ArcGis 10.3 Raster Calculator:
Con("Raster1" == 1,"Raster2","Raster3")
But I get this error:
Con(Raster(r"Raster1") == 1,Raster(r"Raster2"),Raster(r"Raster3"))
ERROR 000539: Error running expression: rcexec()
Traceback (most recent call last):
File "<expression>", line 1, in <module>
File "<string>", line 8, in rcexec
RuntimeError: ERROR 010240: Could not save raster dataset to F:\folder\step13 with output format GRID.
Failed to execute (RasterCalculator).
I tried the same thing using Python:
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "F:/folder"
Ras1 = Raster("Raster1")
Ras2 = Raster("Raster2")
Ras3 = Raster("Raster3")
outCon = Con((Ras1==1),Ras2, Ras3)
outCon.save = ("F:/folder/out")
But I get this error:
RuntimeError: ERROR 000875: Output raster: C:\xxx\xxx\Documents\ArcGIS\Default.gdb\ifthe_ras's workspace is an invalid output workspace.
I'm stuck. I cannot understand what's wrong with my raster calculations.
(('Raster1@1' = 1) * 'Raster2@1') + (('Raster1@1' != 1) * 'Raster3@1')