Kernel Density (Spatial Analyst)

Summary

Calculates a magnitude per unit area from point or polyline features using a kernel function to fit a smoothly tapered surface to each point or polyline.

Learn more about how Kernel Density works

Usage

Syntax

KernelDensity (in_features, population_field, {cell_size}, {search_radius}, {area_unit_scale_factor})
ParameterExplanationData Type
in_features

The input features (point or line) for which to calculate the density.

Feature Layer
population_field

Field denoting population values for each feature. The Population field is the count or quantity to be spread across the landscape to create a continuous surface.

Values in the population field may be integer or floating point.

The options and default behaviours for the field are listed below.

  • Use None if no item or special value will be used and each feature will be counted once.

  • You can use Shape if input features contains Z.

  • Otherwise, the default field is POPULATION. The following conditions may also apply.

    • If there is no POPULATION field, but there is a POPULATIONxxxx field, this is used by default. The "xxxx" can be any valid character, such as POPULATION6, POPULATION1974, or POPULATIONROADTYPE.
    • If there is no POPULATION field or POPULATIONxxxx field, but there is a POP field, this is used by default.
    • If there is no POPULATION field, POPULATIONxxxx field, or POP field, but there is a POPxxxx field, this is used by default.
    • If there is no POPULATION field, POPULATIONxxxx field, POP field, or POPxxxx field, NONE is used by default.
Field
cell_size
(Optional)

The cell size for the output raster dataset.

This is the value in the environment if specifically set. If the environment is not set, then cell size is the shorter of the width or height of the output extent in the output spatial reference, divided by 250.

Analysis Cell Size
search_radius
(Optional)

The search radius within which to calculate density. Units are based on the linear unit of the projection of the output spatial reference.

For example, if the units are in meters, to include all features within a one-mile neighborhood, set the search radius equal to 1609.344 (1 mile = 1609.344 meters).

The default is the shortest of the width or height of the output extent in the output spatial reference, divided by 30.

Double
area_unit_scale_factor
(Optional)

The desired area units of the output density values.

A default unit is selected based on the linear unit of the projection of the output spatial reference. You can change this to the appropriate unit if you wish to convert the density output. Values for line density convert the units of both length and area.

For example, if your input units are meters the default output area density units will be square kilometers for point features or kilometers per square kilometer for polyline features.

The default density units based on the input feature units are:

  • SQUARE_MAP_UNITS If the units are unknown, points, or decimal degrees.
  • SQUARE_MILES For feet, yards, miles, or nautical miles.
  • SQUARE_KILOMETERS For meters or kilometers.
  • SQUARE_INCHES For inches.
  • SQUARE_CENTIMETERS For centimeters.
  • SQUARE_MILLIMETERS For millimeters.
String

Return Value

NameExplanationData Type
out_raster

The output kernel density raster.

It is always a floating point raster.

Raster

Code Sample

KernelDensity example 1 (Python window)

This example calculates a smoothed density raster from a point shape file.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outKDens = KernelDensity("rec_sites.shp", "NONE", 45, 1200, "SQUARE_KILOMETERS")
outKDens.save("C:/sapyexamples/output/kdensout")
KernelDensity example 2 (stand-alone script)

This example calculates a smoothed density raster from a point shape file.

# Name: KernelDensity_Ex_02.py
# Description: Calculates a magnitude per unit area from point or polyline 
#    features using a kernel function to fit a smoothly tapered 
#    surface to each point or polyline.
# Requirements: Spatial Analyst Extension
# Author: ESRI

# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Set environment settings
env.workspace = "C:/sapyexamples/data"

# Set local variables
inFeatures = "rec_sites.shp"
populationField = "NONE"
cellSize = 60
searchRadius = 2500


# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Execute KernelDensity
outKernelDensity = KernelDensity(inFeatures, populationField, cellSize,
                                 searchRadius, "SQUARE_KILOMETERS")

# Save the output 
outKernelDensity.save("C:/sapyexamples/output/kerneldout")

Environments

Related Topics

Licensing Information

ArcView: Requires Spatial Analyst
ArcEditor: Requires Spatial Analyst
ArcInfo: Requires Spatial Analyst

6/29/2011