ArcGIS教程:多边形提取 (空间分析)

  摘要

  基于多边形提取栅格像元。

  用法

  · 若要基于要素类中的多边形提取像元,而不是提供一系列 x,y 坐标对,则可以使用按掩膜提取工具。

  · 可通过像元的中心来确定该像元是位于多边形的内部还是多边形的外部。如果中心位于多边形弧的内部,则即使部分像元落在多边形之外,也会将此像元视为完全处于多边形之内。

  · 多边形最多可以有 1,000 个折点。多边形折点必须按顺时针顺序输入。如果要使用多个多边形,则第一个折点和最后一个折点必须相同,以使多边形闭合。如果最后的点不相同,多边形将自动闭合。多边形的弧之间可以相交,但不建议您使用过于复杂的多边形。

  · 未选择的像元位置被赋予 NoData 值。

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

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

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

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

  代码实例

  多边形提取 (ExtractByPolygon) 示例 1(Python 窗口)

  本示例将基于定义的多边形坐标提取栅格的像元。

  import arcpy

  from arcpy import env

  from arcpy.sa import *

  polyPoints = [arcpy.Point(743050, 4321275), arcpy.Point(743100, 4321200),

  arcpy.Point(743500, 4322000),arcpy.Point(742900, 4321800)]

  env.workspace = “C:/sapyexamples/data”

  extPolygonOut = ExtractByPolygon(“soil”, polyPoints, “INSIDE”)

  extPolygonOut.save(“c:/sapyexamples/output/extpoly”)

  多边形提取 (ExtractByPolygon) 示例 2(独立脚本)

  本示例将基于定义的多边形坐标提取栅格的像元。

  # Name: ExtractByPolgyon_Ex_02.py

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

  # 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 = “soil”

  polyPoints = [arcpy.Point(743050, 4321275), arcpy.Point(743100, 4321200),

  arcpy.Point(743500, 4322000),arcpy.Point(742900, 4321800)]

  # Check out the ArcGIS Spatial Analyst extension license

  arcpy.CheckOutExtension(“Spatial”)

  # Execute ExtractByPolygon

  extPolygonOut = ExtractByPolygon(inRaster, polyPoints, “INSIDE”)

  # Save the output

  extPolygonOut.save(“c:/sapyexamples/output/extpoly02”)

转载自:https://blog.csdn.net/dsac1/article/details/49181361

You may also like...

退出移动版