Hi Mohamad,If you create a Toolbox and want to add a script, you can use the "Weighted Sum" Data Type for the parameter to collect the necessary information.This will return a string with the following structure:rastername1 fieldname1 weight1;rastername2 fieldname2 weight2In the Help on Weighted Sum you can see in the example code that (like Mark explains) a WSTable can be created:wstbl = WSTable([["snow", "VALUE", 0.25], ["land", "VALUE", 0.25],["soil", "VALUE", 0.5]])
If you execute this python code:import arcpy
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
wstbl = WSTable([["snow", "VALUE", 0.25], ["land", "VALUE", 0.25], ["soil", "VALUE", 0.5]])
print wstbl
It will return:'snow' VALUE 0.25; 'land' VALUE 0.25; 'soil' VALUE 0.5... which is a similar structure as the parameter provides.Normally to understand what a tool needs to execute, you can perform it manually and from the Results screen Copy the code as Python Snippet.Although the Help uses a syntax like:output_raster = arcpy.sa.WeightedSum(wstbl)
The copied Python snippet will use:arcpy.gp.WeightedSum_sa("snow VALUE 0.25;land VALUE 0.25;soil VALUE 0.5",output_raster)
I would recommend to use the parameter type "Weighted Sum" and provide that as text to the "arcpy.gp.WeightedSum_sa" tool.import arcpy
arcpy.CheckOutExtension("Spatial")
wstbl = arcpy.GetParameterAsText(0) # list of rasters and weights
out_ras = arcpy.GetParameterAsText(1) # output raster
arcpy.gp.WeightedSum_sa(wstbl,out_ras)
Kind regards, Xander