I'm trying to do the raster calculator with this script but something goes wrong. It seems that the program doesn't found the files, but they exist. I've tried to remove path from the variables (raster1, raster2 etc) but it is the same.
import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.env.workspace = "C:\Users\Elisa\Model_Builder\raster_calc\input"
arcpy.env.overwriteOutput = True
raster1 = "C:\Users\Elisa\Model_Builder\raster_calc\input\lito2016_area_studio_cross_curv.img"
raster2 = "C:\Users\Elisa\Model_Builder\raster_calc\input\lito2016_area_studio_flowacc.img"
raster3 = "C:\Users\Elisa\Model_Builder\raster_calc\input\lito2016_area_studio_long_curv.img"
outRas = Raster("raster1") * Raster("raster3")
outRas.save("C:\Users\Elisa\Model_Builder\raster_calc")
-
Please always provide errors as text rather than pictures.PolyGeo– PolyGeo ♦2018年06月13日 20:28:59 +00:00Commented Jun 13, 2018 at 20:28
1 Answer 1
The path slashes are being interpreted as escape characters, use one of the following path slash formats instead:
raster1 = "C:/Users/Elisa/...
raster1 = r"C:\Users\Elisa\...
raster1 = "C:\\Users\\Elisa\\...
answered Jun 13, 2018 at 12:11
-
i've tried to do it but it still doesn't workElisa m– Elisa m2018年06月13日 13:10:42 +00:00Commented Jun 13, 2018 at 13:10
-
Are you reeving the same or different error?artwork21– artwork212018年06月13日 14:23:40 +00:00Commented Jun 13, 2018 at 14:23
-
The same. I've tried another function in map algebra and it is ok. The problem is in the variable recall but i don't know how to solve it.Elisa m– Elisa m2018年06月13日 14:41:37 +00:00Commented Jun 13, 2018 at 14:41
-
1@ElisaMammoliti remove the quotes in line
outRas = Raster("raster1") * Raster("raster3")
Hornbydd– Hornbydd2018年06月13日 16:16:31 +00:00Commented Jun 13, 2018 at 16:16
Explore related questions
See similar questions with these tags.
lang-py