『公告』 预祝您龙年大吉,万事如意, 过节期间, 大家如需数据服务,请拨打400 或直接添加客服微信,再祝大家龙年,心想事成。
关注我们 新浪 腾讯

ArcGIS教程:按属性提取 (空间分析)

ArcGIS教程:按属性提取 (空间分析)
基于逻辑查询提取栅格像元。

摘要

    基于逻辑查询提取栅格像元。

插图


用法

·      如果 Where 子句的求值结果是 True,则将为该像元位置返回初始输入值。如果其求值结果是 False,则将为像元位置指定 NoData

·      对于输出栅格,将舍弃输入栅格中的所有额外项(计数除外)。

·      如果在 Where 子句中指定了除输入栅格的以外的某一项,则将为此像元位置返回初始输入值。

·      当输入为多波段栅格时,将输出一个新的多波段栅格。对输入多波段栅格中的每一单个波段都会进行相应分析。

默认输出格式是 Esri Grid 堆栈。请注意,Esri Grid 堆栈的名称不能以数字开头、不能使用空格,并且长度不能超过 9 个字符。

·      如果输入内容为根据多波段栅格(超过三个波段)创建的图层,提取操作将只考虑图层加载(符号化)的波段。因此,输出的多波段栅格只会具有三个波段,分别对应于输入图层显示中使用的多波段栅格。

·      如果输入栅格为整型,那么输出栅格也为整型。如果输入栅格为浮点型,则输出栅格也为浮点型。

语法

    ExtractByAttributes (in_raster, where_clause)

参数

说明

数据类型

in_raster

提取像元的输入栅格。

Raster Layer

where_clause

用于选择栅格像元子集的逻辑表达式。

表达式遵循 SQL 表达式的一般格式。

SQL Expression

返回值

名称

说明

数据类型

out_raster

包含提取像元值的输出栅格。

Raster

代码实例

    按属性提取 (ExtractByAttributes) 示例 1Python 窗口)

    本示例将基于逻辑查询从栅格中提取像元,其中高程大于 1,000 米。

import arcpy

from arcpy import env

from arcpy.sa import *

env.workspace = "C:/sapyexamples/data"

attExtract = ExtractByAttributes("elevation", "VALUE > 1000")

attExtract.save("c:/sapyexamples/output/attextract")

    按属性提取 (ExtractByAttributes) 示例 2(独立脚本)

    本示例将基于逻辑查询从栅格中提取像元,其中高程大于 1,000 米。

# Name: ExtractByAttributes_Ex_02.py

# Description: Extracts the cells of a raster based on a logical query.

# 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

inRaster = "elevation"

inSQLClause = "VALUE > 1000"

# Check out the ArcGIS Spatial Analyst extension license

arcpy.CheckOutExtension("Spatial")

# Execute ExtractByAttributes

attExtract = ExtractByAttributes(inRaster, inSQLClause)

# Save the output

attExtract.save("c:/sapyexamples/output/attextract02")

      京ICP备2025132830号-1 京公网安备 号