Tabulate Intersection (Analysis)

License Level:BasicStandardAdvanced

Summary

Computes the intersection between two feature classes and cross-tabulates the area, length, or count of the intersecting features.

Illustration

Tabulate Intersection illustration

Usage

Syntax

TabulateIntersection_analysis (in_zone_features, zone_fields, in_class_features, out_table, {class_fields}, {sum_fields}, {xy_tolerance}, {out_units})
ParameterExplanationData Type
in_zone_features

The features used to identify zones.

Feature Layer
zone_fields
[zone_fields,...]

The attribute field or fields that will be used to define zones.

Field
in_class_features

The features used to identify classes.

Feature Layer
out_table

The table that will contain the cross-tabulation of intersections between zones and classes.

Table
class_fields
[class_fields,...]
(Optional)

The attribute field or fields used to define classes.

Field
sum_fields
[sum_fields,...]
(Optional)

The fields to sum from the Input Class Features.

Field
xy_tolerance
(Optional)

The distance that determines the range in which features or their vertices are considered equal. By default, this is the XY Tolerance of the Input Zone Features.

Linear Unit
out_units
(Optional)

Units to be used to calculate area or length measurements. Setting Output Units when the Input Class Features are points is not supported.

String

Code Sample

TabulateIntersection example 1 (Python window)

Using TabulateIntersection in the Python window to find the area of each vegetation type in each zone.

arcpy.TabulateIntersection_analysis("Zones","zone_id","Vegetation",r"C:\Esri\veganalysis.gdb\vegtypeAreas","VEGTYPE")
TabulateIntersection example 2 (stand-alone script)

Script that wraps TabulateIntersection in order to create a simple TabulateArea script tool. The TabulateArea script tool will only take polygon features as input.

The Zone and Class fields are restricted to one each.

'''
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)

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: No
ArcGIS for Desktop Standard: No
ArcGIS for Desktop Advanced: Yes
5/6/2013