交集制表 (Analysis)

许可等级:BasicStandardAdvanced

摘要

计算两个要素类之间的交集并对相交要素的面积、长度或数量进行交叉制表。

插图

Tabulate Intersection illustration

用法

语法

TabulateIntersection_analysis (in_zone_features, zone_fields, in_class_features, out_table, {class_fields}, {sum_fields}, {xy_tolerance}, {out_units})
参数说明数据类型
in_zone_features

用于标识区域的要素。

Feature Layer
zone_fields
[zone_fields,...]

将用于定义区域的属性字段。

Field
in_class_features

用于标识类的要素。

Feature Layer
out_table

将包含区域和类之间交集的交叉表的表。

Table
class_fields
[class_fields,...]
(可选)

用于定义类的属性字段。

Field
sum_fields
[sum_fields,...]
(可选)

输入类要素中用于求和的字段。

Field
xy_tolerance
(可选)

确定要素或其折点被视作相同的范围的距离。默认情况下,为输入区域要素的 XY 容差。

Linear Unit
out_units
(可选)

计算面积或长度测量值所使用的单位。当输入类要素为点不受支持时,设置输出单位

String

代码实例

制表交集 (TabulateIntersection) 示例 1(Python 窗口)

在 Python 窗口中使用制表交集 (TabulateIntersection) 可查找各区域中每种植被的面积。

arcpy.TabulateIntersection_analysis("Zones","zone_id","Vegetation",r"C:\Esri\veganalysis.gdb\vegtypeAreas","VEGTYPE")
制表交集 (TabulateIntersection) 示例 2(独立脚本)

对制表交集 (TabulateIntersection) 进行打包以创建简单的 TabulateArea 脚本工具的脚本。TabulateArea 脚本工具仅采用面要素作为输入。

“区域”和“类”字段各自限制为一个。

'''
TabulateArea.py
Description: Shows how to wrap the TabulateIntersection tool to create a TabulateArea script tool
Requirements: Polygon Zone Feature Class, Polygon Class Feature Class

'''
import arcpy, sys, os

def AddMsgAndPrint(msg, severity=0):
    # Adds a Message (in case this is run as a tool)
    # and also prints the message to the screen (standard output)
    # 
    print msg

    # Split the message on \n first, so that if it's multiple lines, 
    #  a GPMessage will be added for each line
    try:
        for string in msg.split('\n'):
            # Add appropriate geoprocessing message 
            #
            if severity == 0:
                arcpy.AddMessage(string)
            elif severity == 1:
                arcpy.AddWarning(string)
            elif severity == 2:
                arcpy.AddError(string)
    except:
        pass

## Get Parameters
zoneFC = arcpy.GetParameterAsText(0)
zoneFld = arcpy.GetParameterAsText(1) # Only allow one field
classFC = arcpy.GetParameterAsText(2)
outTab = arcpy.GetParameterAsText(3)
classFld = arcpy.GetParameterAsText(4) # Optional and only allow one field
sum_Fields = ""
xy_tol = ""
outUnits = arcpy.GetParameterAsText(5)

## Validate parameters
# Inputs can only be polygons
zoneDesc = arcpy.Describe(zoneFC)
classDesc = arcpy.Describe(classFC)
if zoneDesc.shapeType != "Polygon" or classDesc.shapeType != "Polygon":
    AddMsgAndPrint("Inputs must be of type polygon.", 2)
    sys.exit()
    
# Only one zone field and class field
if zoneFld != "":
    if zoneFld.find(";") > -1 or classFld.find(";") > -1:
        AddMsgAndPrint("A maximum of one zone and/or class field is allowed.", 2)
        sys.exit()

## Run TI with restricted parameters
try:
    arcpy.TabulateIntersection_analysis(zoneFC, zoneFld, classFC, outTab, classFld, sum_Fields, xy_tol, outUnits)
except:
    arcpy.AddMessage("Tabulate Intersection Failed.")
AddMsgAndPrint(arcpy.GetMessages(), 0)

环境

相关主题

许可信息

ArcGIS for Desktop Basic: 否
ArcGIS for Desktop Standard: 否
ArcGIS for Desktop Advanced: 是
5/10/2014