【问题标题】:GIS/ArcPy: extracting land use data from a raster and assignig to shapefile polygonsGIS/ArcPy:从栅格中提取土地利用数据并将其分配给 shapefile 多边形
【发布时间】:2016-04-12 17:05:06
【问题描述】:

我有两张针对同一地区的地图 (1) 一张栅格土地利用地图和 (2) 一个包含数千个子流域的 shapefile。我正在尝试根据多数规则将栅格(地图 1)中的土地利用类型分配给每个子流域(地图 2)。我尝试了空间连接,但结果似乎是错误的。在 ArcMap 中或通过 arcpy 执行此操作的最佳方法是什么?

【问题讨论】:

  • 你能更好地描述你得到的结果“似乎有问题”吗?空间连接也是我尝试的第一种方法,因此我需要更多详细信息来帮助解决问题。
  • 我的目标是确定重叠区域中最大面积的土地利用,并在 shapefile 多边形中分配该土地利用。在空间连接中,我使用“INTERSECT”作为匹配选项。在“连接特征的字段映射”中,我使用“模式”作为“合并规则”;其他合并规则选项是 Frist、Last、Min、Max、Count、Sum、Mean、StD、Median 和 Range。当我使用“模式”时,它给出了大多数时间出现在重叠区域的“土地利用”类型。但是,我想要的结果是找到重叠区域中表面积最大的土地利用类型。

标签: gis raster arcpy


【解决方案1】:

我建议使用Zonal Statistics as Table (Spatial Analyst) 来完成这项任务。以下是一般工作流程:

  1. 使用“多数”统计运行Zonal Statistics as Table
  2. 使用Join Field (Data Management) 将表与流域要素类连接起来

import arcpy, os
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")

# Your watershed feature class
watersheds = r'C:\path\to\your\geodatabase.gdb\watersheds'

# Your land cover raster
raster = r'C:\path\to\your\landcover_raster.tif'

# The workspace where the output table will go
zone_table = r'C:\path\to\your\geodatabase.gdb'

# Perform the zonal statistics and output a table
arcpy.sa.ZonalStatisticsAsTable (watersheds, 'watershed_id', raster, zone_table, 'DATA', 'MAJORITY')

# Join the table to the watershed feature class by the OBJECTID field (for feature class)
arcpy.JoinField_management(watersheds, 'watershed_id', zone_table, 'OBJECTID', 'MAJORITY')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-17
    • 2021-08-15
    • 2021-07-30
    • 2021-11-24
    • 1970-01-01
    • 1970-01-01
    • 2022-01-24
    • 2014-03-09
    相关资源
    最近更新 更多