Solved! Go to Solution.
# use "r" before path myFGDB = r"C:\A\B\Test\TIMESLOOKUP.gdb" # use forward slashes myFGDB = "C:/A/B/Test/TIMESLOOKUP.gdb" # use double slashes myFGDB = "C:\\A\\B\\Test\\TIMESLOOKUP.gdb"
arcpy.env.workspace = r"C:\A\B\Test\TIMESLOOKUP.gdb" arcpy.env.scratchWorkspace = r"C:\A\B\Test\TIMESLOOKUP.gdb"
arcpy.env.workspace = r"C:\A\B\Test\TIMESLOOKUP.gdb" arcpy.env.scratchWorkspace = r"C:\A\B\Test\TIMESLOOKUP.gdb"
outWS = r'C:\A\B\Test\'
outWS = r'C:\A\B\Test'
fldName1 = 'A' fldName2 = 'B' fldName3 = 'C'
fldName1 = 'Name' fldName2 = 'AP' fldName3 = 'Q'
import arcpy,os inWS = r'C:\A\B\C\EucDistRasters' # input rasters are stored here outWS = r'C:\A\B\Test' # output rasters will be stored here tbl = 'LOOKUP$' fldName1 = 'Name' # field with output raster name (no path included) fldName2 = 'AP' # field with input raster name (no path included) fldName3 = 'Q' # multiply value field fields = [fldName1,fldName2,fldName3] cnt=0 with arcpy.da.SearchCursor(tbl, fields) as cursor: for row in cursor: cnt+=1 value_from_row = row[2] inName = row[1] outName = row[0] inRasLoc = os.path.join(inWS,inName) outRasLoc = os.path.join(outWS,outName) print "Name={0}\tAP={1}\tQ={2}\t".format(outName,inName,value_from_row) print " - inRasLoc ={0}".format(inRasLoc) print " - outRasLoc={0}".format(outRasLoc) if cnt > 5: break del row, tbl
>>> import arcpy,os,arcpy.sa ... arcpy.env.workspace = "C:\A\B\Test\TIMESLOOKUP.gdb" ... arcpy.env.scratchWorkspace = "C:\A\B\Test\TIMESLOOKUP.gdb" ... inWS = r'C:\A\B\C\EucDistRasters' # input rasters are stored here ... outWS = r'C:\A\B\Test\' # output rasters will be stored here ... ... tbl = 'LOOKUP$' ... fldName1 = 'A' # field with output raster name (no path included) ... fldName2 = 'B' # field with input raster name (no path included) ... fldName3 = 'C' # multiply value field ... ... fields = [fldName1,fldName2,fldName3] ... with arcpy.da.SearchCursor(tbl, fields) as cursor: ... for row in cursor: ... value_from_row = row[2] ... inName = row[1] ... outName = row[0] ... inRasLoc = os.path.join(inWS,inName) ... inRas = arcpy.Raster(inRasLoc) ... result = Exp(inRas * value_from_row) ... outRasLoc = os.path.join(outWS,outName) ... result.save(outName) ... ... del row, inRas, tbl
import arcpy,os,arcpy.sa
import arcpy,os from arcpy.sa import *
result = arcpy.sa.Exp(inRas * value_from_row)