Collect Events (Spatial Statistics)

Summary

Converts event data, such as crime or disease incidents, to weighted point data.

Illustration

Collect Events tool illustration

Usage

  • This tool combines coincident points. It creates a new Output Feature Class value that contains the unique locations found in the Input Feature Class value. It then adds an ICOUNT field to hold the sum of all incidents at each unique location.

  • This tool will only combine features that have the exact same x and y centroid coordinates. You can use the Integrate tool to snap nearby features together before running this tool.

    Caution:

    The Integrate tool permanently alters feature geometry; always make a backup copy of the feature class before using the Integrate tool.

  • The Hot Spot Analysis (Getis-Ord Gi*), Cluster and Outlier Analysis (Local Moran's I), and Spatial Autocorrelation (Morans I) tools, for example, require weighted points rather than individual incidents. You can use this tool to create weights when the input feature class contains coincident features.

  • Although this tool will work with polygon or line data, it is only appropriate for event, incident, or other point feature data. For line and polygon features, feature coincidence is based on feature true geometric centroids. For multipoint, polyline, or polygons with multiple parts, the centroid is computed using the weighted mean center of all feature parts. The weighting for point features is 1, for line features is length, and for polygon features is area.

  • If you want each individual point or part of multipoint or multipart data treated as singlepart features, run the Multipart to Singlepart tool. Then run Collect Events on the singlepart feature class. For more information, see Processing Multipoint Data.

  • In addition to the Output Weighted Point Feature Class value, this tool passes, as derived output values, the name of the count field and the maximum count value encountered for any one location. These derived output values are helpful when you use this tool in models or scripts.

Parameters

LabelExplanationData Type
Input Incident Features

The features representing event or incident data.

Feature Layer
Output Weighted Point Feature Class

The output feature class that will contain the weighted point data.

Feature Class

Derived Output

LabelExplanationData Type
Results Field

The name of the count field

Field
Z Max Value

The maximum count value encountered for any one location.

Double

arcpy.stats.CollectEvents(Input_Incident_Features, Output_Weighted_Point_Feature_Class)
NameExplanationData Type
Input_Incident_Features

The features representing event or incident data.

Feature Layer
Output_Weighted_Point_Feature_Class

The output feature class that will contain the weighted point data.

Feature Class

Derived Output

NameExplanationData Type
Results_Field

The name of the count field

Field
Z_Max_Value

The maximum count value encountered for any one location.

Double

Code sample

CollectEvents example 1 (Python window)

The following Python window script demonstrates how to use the CollectEvents function.

import arcpy
arcpy.env.workspace = "C:/Data"
arcpy.stats.CollectEvents("911Copied.shp", "911Count.shp")
CollectEvents example 2 (stand-alone script)

The following stand-alone Python script demonstrates how to use the CollectEvents function.


# Analyze the spatial distribution of 911 calls in a metropolitan area
# using the Hot-Spot Analysis Tool (Local Gi*)

# Import system modules
import arcpy

# Set property to overwrite existing output, by default
arcpy.env.overwriteOutput = True

# Local variables...
workspace = "C:/Data"

try:
    # Set the current workspace (to avoid having to specify the full 
    # path to the feature classes each time)
    arcpy.env.workspace = workspace

    # Copy the input feature class and integrate the points to snap
    # together at 500 feet
    # Process: Copy Features and Integrate
    cf = arcpy.management.CopyFeatures("911Calls.shp", "911Copied.shp")

    integrate = arcpy.management.Integrate("911Copied.shp #", "500 Feet")

    # Use Collect Events to count the number of calls at each location
    # Process: Collect Events
    ce = arcpy.stats.CollectEvents("911Copied.shp", "911Count.shp")

    # Add a unique ID field to the count feature class
    # Process: Add Field and Calculate Field
    af = arcpy.management.AddField("911Count.shp", "MyID", "LONG", "#", 
                     "#", "#", "#", "NON_NULLABLE", "NON_REQUIRED", "#",
                     "911Count.shp")
    
    cf = arcpy.management.CalculateField("911Count.shp", "MyID", 
                                         "!FID!", "PYTHON")

    # Create Spatial Weights Matrix for Calculations
    # Process: Generate Spatial Weights Matrix... 
    swm = arcpy.stats.GenerateSpatialWeightsMatrix("911Count.shp", "MYID",
                        "euclidean6Neighs.swm",
                        "K_NEAREST_NEIGHBORS",
                        "#", "#", "#", 6,
                        "NO_STANDARDIZATION") 

    # Hot Spot Analysis of 911 Calls
    # Process: Hot Spot Analysis (Getis-Ord Gi*)
    hs = arcpy.stats.HotSpots("911Count.shp", "ICOUNT", "911HotSpots.shp", 
                     "GET_SPATIAL_WEIGHTS_FROM_FILE",
                     "EUCLIDEAN_DISTANCE", "NONE",
                     "#", "#", "euclidean6Neighs.swm")

except arcpy.ExecuteError:
    # If an error occurred when running the tool, print the error message.
    print(arcpy.GetMessages())

Environments

Special cases

Output Coordinate System

Feature geometry is projected to the Output Coordinate System prior to analysis. All mathematical computations are based on the Output Coordinate System spatial reference.

Related topics