Tabulate Intersection

Title  Tabulate Intersection

Summary

Geoprocessing tool that cross-tabulates the intersection between two feature classes to determine how much of one feature class' features are inside the other's.


Illustration


Tabulate Intersection illustration

Usage


Syntax

Parameter Explanation
in_zone_features

The features used to identify zones.

zone_fields

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

in_class_features

The features used to identify classes.

out_table

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

class_fields (Optional)

The attribute field or fields used to define classes.

sum_fields (Optional)

The fields to sum from the Input Class Features.

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.

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.

Code Samples

TabulateIntersection example 1 (Python window)

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


import arcpy
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.


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


                    

Tags

Credits

Use limitations