WSTable

Available with Spatial Analyst license.

Available with Image Analyst license.

Summary

Defines the input rasters and their weights which will be added together in the Weighted Sum tool.

Discussion

The Weighted Sum tool uses the WSTable object.

License:

This class is also available if you have an Image Analyst extension license.

Input rasters can be integer or floating point.

The weight values can be any positive or negative decimal value. The weights do not need to add to any specific value such as 100 (representing each raster's percent influence).

Syntax

WSTable (weightedSumTable)
ParameterExplanationData Type
weightedSumTable
[[inRaster, field, weight],...]

The table specifying the input rasters, the fields to use for the values for each raster, and the weight by which to multiply each raster.

  • InRaster—Is the raster being weighted (data type: string).
  • field—The field in the raster to use for the input values (data type: string).
  • weight—The weight value by which to multiple the raster (data type: double).

List

Properties

PropertyExplanationData Type
weightedSumTable
(Read and Write)

Contains the weighted sum table specifying the rasters to be added, the fields identifying the values to use for each raster, and the amount of influence each raster will have in the addition.

List

Code sample

WSTable example 1 (Python window)

Demonstrates how to create a WSTable class and use it in the WeightedSum tool within the Python window.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
myWSumTable = WSTable([["snow", "VALUE", 0.2], ["land", "VALUE", 0.3], ["soil",
                    "VALUE", 0.5]])
outWSumT = WeightedSum(myWSumTable)
outWSumT.save("C:/sapyexamples/output/wsumtable")
WSTable example 2 (stand-alone script)

Performs a weighted sum analysis using the WSTable class.

# Name: WSTable_Ex_02.py
# Description: Demonstrate executing WeightedSum using the WSTable object.
# Requirements: Spatial Analyst Extension

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

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

# Set local variables
inRaster01 = "snow"
field01 = "VALUE"
weight01 = 0.25
inRaster02 = "land"
field02 = "VALUE"
weight02 = 0.25
inRaster03 = "soil"
field03 = "VALUE"
weight03 = 0.5

# Define WSTable 
myWSumTable = WSTable([[inRaster01, field01, weight01], [inRaster02, field02,
                        weight02], [inRaster03, field03, weight03]])

# Execute WeightedSum
outWSumT = WeightedSum(myWSumTable)

# Save the output 
outWSumT.save("C:/sapyexamples/output/wsumtable2")

Related topics