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.

enter image description here

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")
  • Please always provide errors as text rather than pictures.
    – PolyGeo
    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\\...
  • i've tried to do it but it still doesn't work
    – Elisa m
    Jun 13, 2018 at 13:10
  • Are you reeving the same or different error?
    – artwork21
    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
    Jun 13, 2018 at 14:41
  • 1
    @ElisaMammoliti remove the quotes in line outRas = Raster("raster1") * Raster("raster3")
    – Hornbydd
    Jun 13, 2018 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.