加权总和 (空间分析)
插图
![Weighted Sum illustration Weighted Sum illustration](009z/GUID-D7ABDBB3-B782-4BF9-89AC-4FACDE4FC6BD-web.gif)
In the illustration, the cell values are multiplied by their weight factor, and the results are added together to create the output raster. For example, consider the top left cell. The values for the two inputs become (2.2 * 0.75) = 1.65 and (3 * 0.25) = 0.75. The sum of 1.5 and 0.75 is 2.4.
用法
-
将多个栅格数据一起添加的有效方法是输入多个栅格并将所有权重设置为 1。
-
输入栅格可以是整型或浮点型。
-
权重值可以是正的或负的小数值。并不限定该值必须是相对百分比或等于 1.0。
-
权重将应用至输入栅格的指定字段。字段的类型可以是短整型或长整型,双精度型或浮点型。
-
默认情况下,此工具会利用多核处理器。可利用的最大核数限制在 4 个以内。
如果希望工具使用的核数较少,则可使用 parallelProcessingFactor 环境设置。
语法
WeightedSum (in_rasters)
参数 | 说明 | 数据类型 |
in_rasters in_weighted_sum_table |
加权总和工具通过将栅格数据各自乘以指定的权重并合计在一起来叠加多个栅格数据。 叠加分析类用于定义表。WSTable 对象用于指定输入栅格的 Python 列表并对输入栅格进行相应的加权。 WSTable 对象的形式为:
| WSTable |
返回值
名称 | 说明 | 数据类型 |
out_raster |
输出适宜性栅格。 此栅格为浮点类型。 | Raster |
代码实例
WeightedSum 示例 1(Python 窗口)
本示例通过将多个栅格数据合并到一起并应用适当的加权因子来创建适宜性栅格,用以为滑雪场地选址。
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
# Execute WeightedSum
outWeightedSum = WeightedSum(WSTable([["snow", "VALUE", 0.25], ["land", "VALUE",0.25],
["soil", "VALUE", 0.5]]))
outWeightedSum.save("C:/sapyexamples/output/outwsum")
WeightedSum 示例 2(独立脚本)
本示例通过将多个栅格数据合并到一起并应用适当的加权因子来创建适宜性栅格,用以为滑雪场地选址。
# Name: WeightedSum_Ex_02.py
# Description: Overlays several rasters multiplying each by their given
# weight and summing them together.
# 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
inRaster1 = "snow"
inRaster2 = "land"
inRaster3 = "soil"
WSumTableObj = WSTable([[inRaster1, "VALUE", 0.25], [inRaster2, "VALUE", 0.25],
[inRaster3, "VALUE", 0.5]])
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Execute WeightedSum
outWeightedSum = WeightedSum(WSumTableObj)
# Save the output
outWeightedSum.save("C:/sapyexamples/output/weightsumout")
相关主题
许可信息
ArcGIS for Desktop Basic: 需要 Spatial Analyst
ArcGIS for Desktop Standard: 需要 Spatial Analyst
ArcGIS for Desktop Advanced: 需要 Spatial Analyst
5/10/2014