AnsweredAssumed Answered

ArcPy Error :  Can't Multiply Sequence by non-int of type 'list

Question asked by india123 on Feb 21, 2017
Latest reply on Feb 22, 2017 by india123

Hi, 

I am trying to execute an equation into python program considering monthly folder, but I am getting error, Below i have attached reference of the equation also, Where P and R  for rasterlist1 and rasterlist2 respectively, 

 

Error message is.

Traceback (most recent call last):
  File "<module3>", line 23, in <module>
TypeError: can't multiply sequence by non-int of type 'list'

Script i am working, 

import arcpy, os, calendar
import numpy
from arcpy.sa import *
arcpy.env.overwriteOutput = True
arcpy.CheckOutExtension("Spatial")
topWorkspace = r'D:\NPP_GUJARAT_MONSOON'
ws_out = r'D:\NPP_GUJARAT_MONSOON\EVA3'
arcpy.env.workspace = topWorkspace


months = {calendar.month_name[i].upper(): str(i).zfill(3) for i in range(1, 13)} # Get dict of months and month number (i.e. January = 001, March = 003 etc.)


# Step through list of all folders
for folderPath in arcpy.ListWorkspaces():
    baseName = os.path.basename(folderPath).upper()
    if baseName in months: # Test that subfolder is a month name
        monthNumber = months[baseName] # Get month-number for use in output filename
        arcpy.env.workspace = folderPath

        # list rasters (Erlier:*Max_Temper.tif, We changed it to below)
        rasterList1 = arcpy.ListRasters('Precipitat*.tif')
        rasterList2 = arcpy.ListRasters('Solar*.tif')
        print rasterList1, rasterList2

        for ras_name in rasterList1:
            ras_mean = arcpy.Raster(os.path.join(folderPath, ras_name))

        for ras_name in rasterList2:
            ras_mean = arcpy.Raster(os.path.join(folderPath, ras_name))

        outCellStatistics = ((rasterList1 * rasterList2) * ((Square(rasterList1)) + (Square(rasterList2)) + rasterList1 * rasterList2)) /rasterList1 + rasterList2 * ((Square(rasterList1)) + (Square(rasterList2)))


        #Save the output
        outRasterName = os.path.join(ws_out, "EO_{}.tif".format(monthNumber))
        outCellStatistics.save(outRasterName)
        print outRasterName


#print done
print 'done'

                                   

Outcomes