## Summary

Measures the degree of clustering for either high or low values using the Getis-Ord General G statistic.

Learn more about how High/Low Clustering: Getis-Ord General G works

## Illustration

## Usage

The High/Low Clustering tool returns four values: Observed General G, Expected General G, z-score, and p-value. The values are written as messages at the bottom of the Geoprocessing pane during tool execution and passed as derived output values for potential use in models or scripts. You can access the messages by hovering over the progress bar, clicking the pop-out button, or expanding the messages section in the Geoprocessing pane. You can also access the messages for a previously run tool via the geoprocessing history. Optionally, you can use this tool to create an HTML report file with a graphical summary of results. The path to the report will be included with the messages summarizing the tool execution parameters. Click that path to open the report file.

The Input Field should contain a variety of nonnegative values. An error message will appear if the Input Field contains negative values. In addition, the math for this statistic requires some variation in the variable being analyzed; it cannot solve if all input values are 1, for example. To use this tool to analyze the spatial pattern of incident data, consider aggregating your incident data. The Optimized Hot Spot Analysis tool can also be used to analyze the spatial pattern of incident data.

##### Note:

Incident data are points representing events (crime, traffic accidents) or objects (trees, stores) where your focus is on presence or absence rather than some measured attribute associated with each point.

- The z-score and p-value are measures of statistical significance which tell you whether or not to reject the null hypothesis. For this tool, the null hypothesis states that the values associated with features are randomly distributed.
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?

The higher (or lower) the z-score, the stronger the intensity of the clustering. A z-score near zero indicates no apparent clustering within the study area. A positive z-score indicates clustering of high values. A negative z-score indicates clustering of low values.

When the Input Feature Class is not projected (that is, when coordinates are given in degrees, minutes, and seconds) or when the output coordinate system is set to a Geographic Coordinate System, distances are computed using chordal measurements. Chordal distance measurements are used because they can be computed quickly and provide very good estimates of true geodesic distances, at least for points within about thirty degrees of each other. Chordal distances are based on an oblate spheroid. Given any two points on the earth's surface, the chordal distance between them is the length of a line, passing through the three-dimensional earth, to connect those two points. Chordal distances are reported in meters.

##### Caution:

Be sure to project your data if your study area extends beyond 30 degrees. Chordal distances are not a good estimate of geodesic distances beyond 30 degrees.

When chordal distances are used in the analysis, the Distance Band or Threshold Distance parameter, if specified, should be given in meters.

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.

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. The following are additional tips:

- Fixed distance band
The Distance Band or Threshold Distance parameter will ensure that each feature has at least one neighbor. This is important, but often the calculated 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 are given a weight of 1.

For the inverse distance options (Inverse distance, Inverse distance squared, and Zone of indifference), any two points that are coincident will be given a weight of one to avoid zero division. This assures that features are not excluded from analysis.

- Fixed distance band
Additional options for the Conceptualization of Spatial Relationships parameter, including three-dimensional and space-time relationships, are available using the Generate Spatial Weights Matrix tool. To take advantage of these additional options, construct a 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 a .swm extension, this tool is expecting a spatial weights matrix file created using the Generate Spatial Weights Matrix tool; 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.
- 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.

- ASCII-formatted spatial weights matrix files:
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.

The Modeling Spatial Relationships help topic provides additional information about this tool's parameters.

##### 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.

## Syntax

HighLowClustering(Input_Feature_Class, Input_Field, {Generate_Report}, Conceptualization_of_Spatial_Relationships, Distance_Method, Standardization, {Distance_Band_or_Threshold_Distance}, {Weights_Matrix_File}, {number_of_neighbors})

Parameter | Explanation | Data Type |

Input_Feature_Class | The feature class for which the General G statistic will be calculated. | Feature Layer |

Input_Field | The numeric field to be evaluated. | Field |

Generate_Report (Optional) | - NO_REPORT —No graphical summary will be created. This is the default.
- GENERATE_REPORT —A graphical summary will be created as an HTML file.
| Boolean |

Conceptualization_of_Spatial_Relationships | Specifies how spatial relationships among features are defined. - 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 (Distance_Band_or_Threshold) receive a weight of one 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 (Distance_Band_or_Threshold) of a target feature receive a weight of one 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.
- K_NEAREST_NEIGHBORS —The closest k features are included in the analysis; k is a specified numeric parameter.
- 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 by a specified spatial weights file. The path to the spatial weights file is specified by 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 | Specifies whether standardization of spatial weights will be applied. Row standardization is recommended whenever the distribution of your features is potentially biased due to sampling design or an imposed aggregation scheme. - NONE —No standardization of spatial weights is applied.
- ROW —Spatial weights are standardized; each weight is divided by its row sum (the sum of the weights of all neighboring features). This is the default.
| String |

Distance_Band_or_Threshold_Distance (Optional) | Specifies a cutoff distance for the 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 that every feature has at least one neighbor. This parameter has no effect when polygon contiguity (CONTIGUITY_EDGES_ONLY or CONTIGUITY_EDGES_CORNERS) or GET_SPATIAL_WEIGHTS_FROM_FILE spatial conceptualizations are selected. | Double |

Weights_Matrix_File (Optional) | The path to a file containing weights that define spatial, and potentially temporal, relationships among features. | File |

number_of_neighbors (Optional) | An integer specifying the number of neighbors that will be included in the analysis. | Long |

## Code sample

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

```
import arcpy
arcpy.env.workspace = r"C:\data"
arcpy.HighLowClustering_stats("911Count.shp", "ICOUNT", "false", "GET_SPATIAL_WEIGHTS_FROM_FILE", "EUCLIDEAN_DISTANCE", "NONE", "#", "euclidean6Neighs.swm")
```

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

```
# Analyze the spatial distribution of 911 calls in a metropolitan area
# using the High/Low Clustering (Getis-Ord General G) tool
# Import system modules
import arcpy
# Set property to overwrite existing outputs
arcpy.env.overwriteOutput = True
# Local variables...
workspace = r"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!", "PYTHON")
# 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")
# Cluster Analysis of 911 Calls
# Process: High/Low Clustering (Getis-Ord General G)
hs = arcpy.HighLowClustering_stats("911Count.shp", "ICOUNT",
"false",
"GET_SPATIAL_WEIGHTS_FROM_FILE",
"EUCLIDEAN_DISTANCE", "NONE",
"#", "euclidean6Neighs.swm")
except arcpy.ExecuteError:
# 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. All mathematical computations are based on the Output Coordinate System spatial reference. When the Output Coordinate System is based on degrees, minutes, and seconds, geodesic distances are estimated using chordal distances.

## Licensing information

- Basic: Yes
- Standard: Yes
- Advanced: Yes