WSTable (arcpy.sa)

摘要

定义将要在 WeightedSum 工具中相加的输入栅格及其权重。

讨论

加权总和工具使用 WSTable 对象。

输入栅格可以是整型或浮点型。

权重值可以是正的或负的小数值。权重总和不必为任何特定值(例如 100,表示每个栅格的影响力百分比)。

语法

WSTable (weightedSumTable)
参数说明数据类型
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

属性

属性说明数据类型
weightedSumTable
(读写)

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

代码实例

WSTable 示例 1(Python 窗口)

演示如何创建 WSTable 类以及如何在 Python 窗口的 WeightedSum 工具中使用该类。

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 示例 2(独立脚本)

使用 WSTable 类执行加权总和分析。

# 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]])

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

# Execute WeightedSum
outWSumT = WeightedSum(myWSumTable)

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

相关主题

5/10/2014