from arcpy import *

#pathway to all rasters in workspace directory
rasters = arcpy.ListRasters('*.tif')
# Local variables:
Output_raster = "test_script.tif"

# Local variables:
aa = "flam_length_new.tif"
bb = "burn_prob.tif"
cc = "us_drought_prob.tif"
dd = "100m_fire_prec.tif"

# Process: Raster Calculator
arcpy.gp.RasterCalculator_sa("(\"flam_length_new.tif")*(Lookup(\"burn_prob.tif\",'Probabilit')*0.6)+(Lookup(\"us_drought_prob.tif\",'Ptobabilit')*0.2)+(Lookup(\"us_fire_1000m_proba.tif\",'prob')*0.3)", Output_raster)

error is:-

Warning (from warnings module): File "", line 1 SyntaxWarning: import * only allowed at module level

Traceback (most recent call last): File "D:\work\scripts\risk_score.py", line 30, in arcpy.gp.RasterCalculator_sa("(\"flam_length_new.tif\")*(Lookup(\"burn_prob.tif\",'Probabilit')*0.6)+(Lookup(\"us_drought_prob.tif\",'Ptobabilit')*0.2)+(Lookup(\"us_fire_1000m_proba.tif\",'prob')*0.3)", Output_raster) File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\geoprocessing_base.py", line 510, in return lambda *args: val(*gp_fixargs(args, True)) ExecuteError: ERROR 000539: Error running expression: rcexec() Traceback (most recent call last): File "", line 1, in File "", line 8, in rcexec RuntimeError: ERROR 999998: Unexpected Error.

Failed to execute (RasterCalculator).


First thing you have to do is import your modules correctly. Please just write import arcpy.

Second thing that i see is so complicated this command:

arcpy.gp.RasterCalculator_sa("(\"flam_length_new.tif")*(Lookup(\"burn_prob.tif\",'Probabilit')*0.6)+(Lookup(\"us_drought_prob.tif\",'Ptobabilit')*0.2)+(Lookup(\"us_fire_1000m_proba.tif\",'prob')*0.3)", Output_raster)

Did you test this expression on arcmap manual? And why are you using arcpy.gp.rastercalculator; it's only useful on modelbuilder. You need to use arcpy map algebra. By the way i don't believe that you can collect your result when you type gp rastercalculator then immediately execute for lookup.. I think you need to do those step by step.

  • I am multiplying some factor in Three different Rasters, because of that i am using gp.rastercalculator, arcpy map algebra is througing some errors – Robot Jun 1 '18 at 11:59

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.