Weighted Sum (Image Analyst)

Summary

Overlays several rasters, multiplying each by their given weight and summing them together.

Usage

• A useful way to add several rasters together is to input multiple rasters and set all weights equal to 1.

• Input rasters can be integer or floating point.

• The weight values can be any positive or negative decimal value. It is not restricted to a relative percentage nor does it need to be equal to 1.0.

• The weight will be applied to the specified field for the input raster. Fields can be of type short or long integer, double or float.

• By default, this tool will take advantage of multicore processors. The maximum number of cores that can be used is four.

To use fewer cores, use the parallelProcessingFactor environment setting.

Parameters

 Label Explanation Data Type Input rasters The weighted sum table allows you to apply different weights to individual input rasters before they are summed together.Raster—The raster being weighted.Field—The field of the raster to use for weighting.Weight—The weight value by which to multiply the raster. It can be any positive or negative decimal value. WSTable

Return Value

 Label Explanation Data Type Output raster The output weighted raster. It will be of floating-point type. Raster

`WeightedSum(in_rasters)`
 Name Explanation Data Type in_rasters TheWeighted Sum tool overlays several rasters, multiplying each by their given weight and summing them together.An Overlay class is used to define the table. The WSTable object is used to specify a Python list of input rasters and weight them accordingly.The form of the object is: WSTable(weightedSumTable) WSTable

Return Value

 Name Explanation Data Type out_raster The output weighted raster. It will be of floating-point type. Raster

Code sample

WeightedSum example 1 (Python window)

This example creates a suitability raster for locating a ski resort by combining multiple rasters together and applying appropriate weight factors.

``````import arcpy
from arcpy import env
from arcpy.ia import *
env.workspace = "C:/data"

# Execute WeightedSum
outWeightedSum = WeightedSum("snow VALUE 0.25;land VALUE 0.25;soil VALUE 0.5")

outWeightedSum.save("C:/output/outwsum")``````
WeightedSum example 2 (stand-alone script)

This example creates a suitability raster for locating a ski resort by combining multiple rasters together and applying appropriate weight factors.

``````# Name: WeightedSum_Ex_02.py
# Description: Overlays several rasters multiplying each by their given
#    weight and summing them together.

# Import system modules
import arcpy
from arcpy import env
from arcpy.ia import *

# Set environment settings
env.workspace = "C:/iapyexamples/data"

# Check out the ArcGIS Image Analyst extension license
arcpy.CheckOutExtension("ImageAnalyst")

wstable = "c:\\test\\Clip_dem.tif VALUE 50;c:\\test\\Clip_aspect.tif VALUE 50"

# Execute WeightedSum
outWeightedSum = WeightedSum(wstable)

# Save the output
outWeightedSum.save("C:/iapyexamples/output/weightsumout")``````

Licensing information

• Basic: Requires Image Analyst or Spatial Analyst
• Standard: Requires Image Analyst or Spatial Analyst
• Advanced: Requires Image Analyst or Spatial Analyst