示例 (空间分析)
用法
-
输入位置是栅格时,位置像元集包括值大于等于零的所有像元。位置集中不包括具有 NoData 值的像元。可使用提取工具轻松创建位置栅格。
-
对输入栅格中的 NoData 像元进行采样的位置将被赋予空值。对于 shapefile,不支持空值,并会为其赋予 0(零)值。
-
如果输入栅格中的栅格是整数,则像元值将保持整数,即使为重采样技术选择了“双线性”或“双三次卷积”选项也会如此。
-
输入栅格和位置栅格的像元大小和配准应相同。
-
工具的输出为表。
语法
Sample (in_rasters, in_location_data, out_table, {resampling_type})
| 参数 | 说明 | 数据类型 |
in_rasters [in_raster,...] |
将根据输入位置数据对其中的值进行采样的栅格列表。 | Raster Layer |
in_location_data |
用于识别想要进行采样的位置的数据。 它可以是栅格,也可以是点要素数据集。 | Raster Layer | Feature Layer |
out_table |
保存已采样的像元值的输出表。 | Table |
resampling_type (可选) |
对栅格进行采样时所使用的重采样算法。
| String |
代码示例
采样示例 1(Python 窗口)
根据输入位置将像元值从多个栅格提取到表。
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
Sample(["elevation", "costraster"], "observers.shp",
"c:/sapyexamples/output/samptable","NEAREST")
采样示例 2(独立脚本)
根据输入位置将像元值从多个栅格提取到表。
# Name: Sample_Ex_02.py
# Description: Creates a table that shows the values of cells from
# a raster, or set of rasters, for defined locations.
# The locations are defined by raster cells or by a set
# of points.
# 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
inRasters = ["elevation",
"costraster"]
locations = "observers.shp"
outTable = "c:/sapyexamples/output/samptable02"
sampMethod = "NEAREST"
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Execute Sample
Sample(inRasters, locations, outTable, sampMethod)
相关主题
许可信息
ArcView: 需要 Spatial Analyst
ArcEditor: 需要 Spatial Analyst
ArcInfo: 需要 Spatial Analyst
7/10/2012