Calculate Distance Band from Neighbor Count (Spatial Statistics)

License Level:BasicStandardAdvanced


Returns the minimum, the maximum, and the average distance to the specified Nth nearest neighbor (N is an input parameter) for a set of features. Results are accessible from the Results window.


Calculate Distance Band from Neighbor Count illustration



CalculateDistanceBand_stats (Input_Features, Neighbors, Distance_Method)
ParameterExplanationData Type

The feature class or layer used to calculate distance statistics.

Feature Layer

The number of neighbors (N) to consider for each feature. This number should be any integer between one and the total number of features in the feature class. A list of distances between each feature and its Nth neighbor is compiled, and the maximum, minimum, and average distances are output to the Results window.


Specifies how distances are calculated from each feature to neighboring features.

  • EUCLIDEAN_DISTANCEThe straight-line distance between two points (as the crow flies)
  • MANHATTAN_DISTANCEThe distance between two points measured along axes at right angles (city block); calculated by summing the (absolute) difference between the x- and y-coordinates

Code Sample

CalculateDistanceBandfromNeighborCount Example (Python Window)

The following Python Window script demonstrates how to use the CalculateDistanceBandfromNeighborCount tool.

import arcpy
arcpy.env.workspace = "c:/data"
mindist, avgdist, maxdist = arcpy.CalculateDistanceBand_stats("Blocks", 10, "EUCLIDEAN_DISTANCE")
CalculateDistanceBandfromNeighborCount Example (stand-alone Python script)

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

# import module
import arcpy

# Set geoprocessing environment Workspace
arcpy.env.workspace = "c:/data"

# Set variables 
infc = "Blocks"
field = "POP2000"
outfc = "PopHotSpots"
neighbors = 10
# Run the CalculateDistanceBand tool to get a distance for use with the Hot Spot tool from the tool result object
mindist, avgdist, maxdist = arcpy.CalculateDistanceBand_stats(infc, neighbors, "EUCLIDEAN_DISTANCE")
# Run the Hot Spot Analysis tool, using the maxdist output from the Calculate Distance Band tool as an input
arcpy.HotSpots_analysis(infc, field, outfc, "Fixed Distance Band", "EUCLIDEAN_DISTANCE", "None", maxdist)


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

Licensing Information

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