I have a problem when using the con()
argument.
What I want to do is to remap all raster of a raster file ("Red_SL") cells with values larger than 40 to the new value 5. All other values should be replaced by another raster file called "remap2". "remap" 2 contains only 4 definite values (1,2,3,4), and "Red SL" has continuous values between 0 and 90.
My syntax is the following:
import arcpy
from arcpy.sa import *
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r"D:\\Projekt\\Testprojekt\\Daten\\Ergebnisse\\"
arcpy.CheckOutExtension("Spatial")
remaped2 = "remaped2.img"
slope = "Red_SL"
CF= Con((slope < 40), 5, remaped2)
CF.save("Red_SL_Neigung_int.tif")
arcpy.CheckInExtension("Spatial")
now the problem is: I do not get an error message but the produced file is nonsense! Python is somehow not able to recognize the slope value in: CF= Con((slope < 40), 5, total) This means it doesent matter what value I give python (here I set it to 40, but I will get the exact same result if I give values of 1 or 3000), the result will always be the a new file which is exactly the same as "remaped2". Python therefore thinks all values are below 40 (or whatever number I give), which is not true.
The exact opposite happens if I change the "<" to ">" (CF= Con((slope > 40), 5, total))
.
Now I will get i new file, which has only 5 in every raster cell. Here again the value whch I type in (instead of 40) does not matter, any value between 1 and 3000 will produce the exact same result. I double checked, but the file "Red_SL" has all values between 0 and 90, therfore the result I get from python is nonsense.
I already tried (without sucess): -Change "Red_SL" from floating to integer -try differend formats (tif, grid, img) for "Red_SL" - replace comma in floating raster with points (german vs. englisch delimiters)
Can anyone see what is wrong with my use of the Con arguement?