# Hot Spot Analysis (Getis-Ord Gi*) (Spatial Statistics)

## Summary

Given a set of weighted features, identifies statistically significant hot spots and cold spots using the Getis-Ord Gi* statistic.

## Usage

• This tool identifies statistically significant spatial clusters of high values (hot spots) and low values (cold spots). It creates a new Output Feature Class with a z-score and p-value for each feature in the Input Feature Class. It also returns the z-score and p-value field names as derived output values for potential use in custom models and scripts.

• The z-scores and p-values are measures of statistical significance which tell you whether or not to reject the null hypothesis, feature by feature. In effect, they indicate whether the observed spatial clustering of high or low values is more pronounced than one would expect in a random distribution of those same values.

• A high z-score and small p-value for a feature indicates a spatial clustering of high values. A low negative z-score and small p-value indicates a spatial clustering of low values. The higher (or lower) the z-score, the more intense the clustering. A z-score near zero indicates no apparent spatial clustering.

• The z-score is based on the randomization null hypothesis computation. For more information on z-scores, see What is a z-score? What is a p-value?

• Calculations based on either Euclidean or Manhattan distance require projected data to accurately measure distances.

• For line and polygon features, feature centroids are used in distance computations. For multipoints, polylines, 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.

• The Input Field should contain a variety of values. The math for this statistic requires some variation in the variable being analyzed; it cannot solve if all input values are 1, for example. If you want to use this tool to analyze the spatial pattern of incident data, consider aggregating your incident data.

• Your choice for the Conceptualization of Spatial Relationships parameter should reflect inherent relationships among the features you are analyzing. The more realistically you can model how features interact with each other in space, the more accurate your results will be. Recommendations are outlined in Selecting a Conceptualization of Spatial Relationships: Best Practices. Here are some additional tips:

• FIXED_DISTANCE_BAND

The default Distance Band or Threshold Distance will ensure each feature has at least one neighbor, and this is important. But often, this default will not be the most appropriate distance to use for your analysis. Additional strategies for selecting an appropriate scale (distance band) for your analysis are outlined in Selecting a fixed distance band value.

• INVERSE_DISTANCE or INVERSE_DISTANCE_SQUARED

When zero is entered for the Distance Band or Threshold Distance parameter, all features are considered neighbors of all other features; when this parameter is left blank, the default distance will be applied.

Weights for distances less than 1 become unstable when they are inverted. Consequently, the weighting for features separated by less than 1 unit of distance (common with Geographic Coordinate System projections) are given a weight of 1.

Caution:

Analysis on features with a Geographic Coordinate System projection is not recommended when you select any of the inverse distance-based spatial conceptualization methods (INVERSE_DISTANCE, INVERSE_DISTANCE_SQUARED, or ZONE_OF_INDIFFERENCE).

For the inverse distance options (INVERSE_DISTANCE, INVERSE_DISTANCE_SQUARED, or ZONE_OF_INDIFFERENCE), any two points that are coincident will be given a weight of one to avoid zero division. This assures features are not excluded from analysis.

• Additional options for the Conceptualization of Spatial Relationships parameter, including space-time relationships, are available using the Generate Spatial Weights Matrix or Generate Network Spatial Weights tools. To take advantage of these additional options, use one of these tools to construct the spatial weights matrix file prior to analysis; select GET_SPATIAL_WEIGHTS_FROM_FILE for the Conceptualization of Spatial Relationships parameter; and for the Weights Matrix File parameter, specify the path to the spatial weights file you created.

• Map layers can be used to define the Input Feature Class. When using a layer with a selection, only the selected features are included in the analysis.

• If you provide a Weights Matrix File with an SWM extension, this tool is expecting a spatial weights matrix file created using either the Generate Spatial Weights Matrix or Generate Network Spatial Weights tools; otherwise, this tool is expecting an ASCII formatted spatial weights matrix file. In some cases, behavior is different depending on which type of spatial weights matrix file you use:

• ASCII-formatted spatial weights matrix files:
• Weights are used as is. Missing feature-to-feature relationships are treated as zeros.
• The default weight for self potential is zero, unless you specify a Self Potential Field value, or include self potential weights explicitly.
• If the weights are row standardized, results will likely be incorrect for analyses on selection sets. If you need to run your analysis on a selection set, convert the ASCII spatial weights file to an SWM file by reading the ASCII data into a table, then using the CONVERT_TABLE option with the Generate Spatial Weights Matrix tool.
• SWM-formatted spatial weights matrix file:
• If the weights are row standardized, they will be restandardized for selection sets; otherwise, weights are used as is.
• The default weight for self potential is one, unless you specify a Self Potential Field value.

• Running your analysis with an ASCII formatted spatial weights matrix file is memory intensive. For analyses on more than 5,000 features, consider converting your ASCII-formatted spatial weights matrix file into an SWM formatted file. First put your ASCII weights into a formatted table (using Excel, for example). Next, run the Generate Spatial Weights Matrix tool using CONVERT_TABLE for the Conceptualization of Spatial Relationships parameter. The output will be an SWM-formatted spatial weights matrix file.

• When this tool runs in ArcMap, the Output Feature Class is automatically added to the table of contents with default rendering applied to the z-score field. The hot-to-cold rendering applied is defined by a layer file in <ArcGIS>/Desktop10.x/ArcToolbox/Templates/Layers. You can reapply the default rendering, if needed, by importing the template layer symbology.

• The Output Feature Class includes a SOURCE_ID field which allows you to Join it to the Input Feature Class, if needed.

• Caution:

When using shapefiles, keep in mind that they cannot store null values. Tools or other procedures that create shapefiles from nonshapefile inputs may store or interpret null values as zero. In some cases, nulls are stored as very large negative values in shapefiles. This can lead to unexpected results. See Geoprocessing considerations for shapefile output for more information.

Legacy:

Prior to ArcGIS 10.0, the output feature class was a duplicate of the input feature class with the z-score and p-value results fields added. After ArcGIS 10.0, the output feature class only includes the z-score and p-value fields as well as the fields input for the analysis. To join other input fields to the output feature class, use the SOURCE_ID field to join the fields using tools in the Joins toolset.

Legacy:

Row Standardization has no impact on this tool: results from Hot Spot Analysis (the Getis-Ord Gi* statistic) would be identical with or without row standardization. The parameter is consequently disabled; it remains as a tool parameter only to support backwards compatibility.

## Syntax

HotSpots_stats (Input_Feature_Class, Input_Field, Output_Feature_Class, Conceptualization_of_Spatial_Relationships, Distance_Method, Standardization, {Distance_Band_or_Threshold_Distance}, {Self_Potential_Field}, {Weights_Matrix_File})
 Parameter Explanation Data Type Input_Feature_Class The feature class for which hot spot analysis will be performed. Feature Layer Input_Field The numeric count field (number of victims, crimes, jobs, and so on) to be evaluated. Field Output_Feature_Class The output feature class to receive the z-score and p-value results. Feature Class Conceptualization_of_Spatial_Relationships Specifies how spatial relationships among features are conceptualized. INVERSE_DISTANCE —Nearby neighboring features have a larger influence on the computations for a target feature than features that are far away. INVERSE_DISTANCE_SQUARED —Same as INVERSE_DISTANCE except that the slope is sharper, so influence drops off more quickly, and only a target feature's closest neighbors will exert substantial influence on computations for that feature. FIXED_DISTANCE_BAND —Each feature is analyzed within the context of neighboring features. Neighboring features inside the specified critical distance receive a weight of 1 and exert influence on computations for the target feature. Neighboring features outside the critical distance receive a weight of zero and have no influence on a target feature's computations. ZONE_OF_INDIFFERENCE —Features within the specified critical distance of a target feature receive a weight of 1 and influence computations for that feature. Once the critical distance is exceeded, weights (and the influence a neighboring feature has on target feature computations) diminish with distance. CONTIGUITY_EDGES_ONLY —Only neighboring polygon features that share a boundary or overlap will influence computations for the target polygon feature. CONTIGUITY_EDGES_CORNERS —Polygon features that share a boundary, share a node, or overlap will influence computations for the target polygon feature. GET_SPATIAL_WEIGHTS_FROM_FILE —Spatial relationships are defined in a spatial weights file. The path to the spatial weights file is specified in the Weights Matrix File parameter. String Distance_Method Specifies how distances are calculated from each feature to neighboring features. EUCLIDEAN_DISTANCE —The straight-line distance between two points (as the crow flies) MANHATTAN_DISTANCE —The distance between two points measured along axes at right angles (city block); calculated by summing the (absolute) difference between the x- and y-coordinates String Standardization Row standardization has no impact on this tool: results from Hot Spot Analysis (the Getis-Ord Gi* statistic) would be identical with or without row standardization. The parameter is disabled; it remains as a tool parameter only to support backwards compatibility. NONE —No standardization of spatial weights is applied. ROW —Disabled. String Distance_Band_or_Threshold_Distance(Optional) Specifies a cutoff distance for Inverse Distance and Fixed Distance options. Features outside the specified cutoff for a target feature are ignored in analyses for that feature. However, for Zone of Indifference, the influence of features outside the given distance is reduced with distance, while those inside the distance threshold are equally considered. The distance value entered should match that of the output coordinate system. For the Inverse Distance conceptualizations of spatial relationships, a value of 0 indicates that no threshold distance is applied; when this parameter is left blank, a default threshold value is computed and applied. This default value is the Euclidean distance that ensures every feature has at least one neighbor. This parameter has no effect when Polygon Contiguity or Get Spatial Weights From File spatial conceptualizations are selected. Double Self_Potential_Field(Optional) The field representing self potential: the distance or weight between a feature and itself. Field Weights_Matrix_File(Optional) The path to a file containing weights that define spatial, and potentially temporal, relationships among features. File

## Code Sample

HotSpotAnalysis example 1 (Python window)

The following Python window script demonstrates how to use the HotSpotAnalysis tool.

``````import arcpy
arcpy.env.workspace = "C:/data"
arcpy.HotSpots_stats("911Count.shp", "ICOUNT", "911HotSpots.shp","GET_SPATIAL_WEIGHTS_FROM_FILE","EUCLIDEAN_DISTANCE", "NONE","#", "#", "euclidean6Neighs.swm")
``````
HotSpotAnalysis example 2 (stand-alone Python script)

The following stand-alone Python script demonstrates how to use the HotSpotAnalysis tool.

``````# 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 geoprocessor object property to overwrite existing output, by default
arcpy.gp.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.CopyFeatures_management("911Calls.shp", "911Copied.shp",
"#", 0, 0, 0)

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

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

# Add a unique ID field to the count feature class
# Process: Add Field and Calculate Field
af = arcpy.AddField_management("911Count.shp", "MyID", "LONG", "#", "#", "#", "#",
"NON_NULLABLE", "NON_REQUIRED", "#",
"911Count.shp")

cf = arcpy.CalculateField_management("911Count.shp", "MyID", "[FID]", "VB")

# Create Spatial Weights Matrix for Calculations
# Process: Generate Spatial Weights Matrix...
swm = arcpy.GenerateSpatialWeightsMatrix_stats("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.HotSpots_stats("911Count.shp", "ICOUNT", "911HotSpots.shp",
"GET_SPATIAL_WEIGHTS_FROM_FILE",
"EUCLIDEAN_DISTANCE", "NONE",
"#", "#", "euclidean6Neighs.swm")

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

## Environments

Output Coordinate System

Feature geometry is projected to the Output Coordinate System prior to analysis, so values entered for the Distance Band/Threshold Distance parameter should match those specified in the Output Coordinate System. All mathematical computations are based on the Output Coordinate System spatial reference.

## Licensing Information

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes