Available with Spatial Analyst license.

## Summary

Calculates a statistic on the points in a neighborhood around each output cell.

## Usage

The Output cell size can be defined by a numeric value or obtained from an existing raster dataset. If the cell size hasn’t been explicitly specified as the parameter value, it is derived from the Cell Size environment if it has been specified. If the parameter cell size or the environment cell size have not been specified, but the Snap Raster environment has been set, the cell size of the snap raster is used. If nothing is specified, the cell size is calculated from the shorter of the width or height of the extent divided by 250, in which the extent is in the Output Coordinate System specified in the environment.

If the cell size is specified using a numeric value, the tool will use it directly for the output raster.

If the cell size is specified using a raster dataset, the parameter will show the path of the raster dataset instead of the cell size value. The cell size of that raster dataset will be used directly in the analysis, provided the spatial reference of the dataset is the same as the output spatial reference. If the spatial reference of the dataset is different than the output spatial reference, it will be projected based on the selected Cell Size Projection Method.

When the specified field is integer, the available overlay statistic choices are Mean, Majority, Maximum, Median, Minimum, Minority, Range, Standard deviation, Sum, and Variety. When the field is floating point, the only allowed statistics are Mean, Maximum, Minimum, Range, Standard deviation, and Sum.

For statistic types Majority, Maximum, Median, Minimum, Minority, Range, and Sum, the output data type of the raster will be the same as the input field type. For statistic types Mean and Standard deviation, the output raster will always be floating point. For Variety, the output raster will always be integer.

If there aren't any points in the neighborhood of a raster cell, the Variety statistic assigns it a value of 0. For the other statistics, NoData is assigned.

See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.

## Syntax

PointStatistics(in_point_features, field, {cell_size}, {neighborhood}, {statistics_type})

Parameter | Explanation | Data Type |

in_point_features | The input point features for which to calculate the statistics in a neighborhood around each output cell. The input can be either a point or multipoint feature class. | Feature Layer |

field | The field that the specified statistic will be calculated for. It can be any numeric field of the input features. It can be the Shape field if the input features contain z-values. | Field |

cell_size (Optional) | The cell size of the output raster that will be created. This parameter can be defined by a numeric value or obtained from an existing raster dataset. If the cell size hasn't been explicitly specified as the parameter value, the environment cell size value will be used if specified; otherwise, additional rules will be used to calculate it from the other inputs. See the usage section for more detail. | Analysis Cell Size |

neighborhood (Optional) | The Neighborhood class dictates the shape of the area around each input point used to calculate the statistic. The available neighborhood types are NbrAnnulus, NbrCircle, NbrRectangle, and NbrWedge. The following are the forms of the neighborhoods: - NbrAnnulus({innerRadius}, {outerRadius}, {units})
- NbrCircle({radius}, {units}
- NbrRectangle({width}, {height}, {units})
- NbrWedge({radius}, {startAngle}, {endAngle}, {units})
The default neighborhood is a square NbrRectangle with a width and height of three cells. | Neighborhood |

statistics_type (Optional) | Specifies the statistic type to be calculated. The calculation is performed on the values of the specified field of the point input in the neighborhood of each output raster cell. - MEAN —Calculates the average of the field values in each neighborhood.
- MAJORITY —Determines the most frequently occurring field value in each neighborhood. In the case of a tie, the lower value is used.
- MAXIMUM —Determines the largest field value in each neighborhood.
- MEDIAN —Determines the median field value in each neighborhood. In the case of an even number of points in the neighborhood, the result will be the lower of the two middle values.
- MINIMUM —Determines the smallest field value in each neighborhood.
- MINORITY —Determines the least frequently occurring field value in each neighborhood. In the case of a tie, the lower value is used.
- RANGE —Calculates the range (difference between largest and smallest) of the field values in each neighborhood.
- STD —Calculates the standard deviation of the field values in each neighborhood.
- SUM —Calculates the total of the field values in each neighborhood.
- VARIETY —Calculates the number of unique field values in each neighborhood.
The available choices for the statistics type is determined by the numeric type of the specified field. | String |

#### Return Value

Name | Explanation | Data Type |

out_raster | The output point statistics raster. | Raster |

## Code sample

This example determines a statistic (the sum) on the input shapefile point features that fall in a circular neighborhood around each output raster cell.

```
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outPointStats = PointStatistics("ca_ozone_pts.shp", "OZONE", 500,
NbrCircle(10000, "MAP"), "SUM")
outPointStats.save("C:/sapyexamples/output/pointstatsout")
```

This example determines a statistic (the average) on the input shapefile point features that fall in a circular neighborhood around each output raster cell.

```
# Name: PointStatistics_Ex_02.py
# Description: Calculates a statistic on points over a specified
# neighborhood outputting a raster.
# Requirements: Spatial Analyst Extension
# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *
# Set environment settings
env.workspace = "C:/sapyexamples/data"
# Set local variables
inPointFeatures = "ca_ozone_pts.shp"
field = "OZONE"
cellSize = 500
neighborhood = NbrCircle(6000, "MAP")
# Execute PointStatistics
outPointStatistics = PointStatistics(inPointFeatures, field, cellSize,
neighborhood, "MEAN")
# Save the output
outPointStatistics.save("C:/sapyexamples/output/pointstatout")
```

## Environments

## Licensing information

- Basic: Requires Spatial Analyst
- Standard: Requires Spatial Analyst
- Advanced: Requires Spatial Analyst