Skip To Content

Calculate Density

Summary

Creates a density map from point or line features by spreading known quantities of some phenomenon (represented as attributes of the points or lines) across the map. The result is a layer of areas classified from least dense to most dense.

Illustration

Calculate Density tool

Usage

  • Larger values of the radius parameter produce a density raster that is smoother. Smaller values produce a raster that changes more abruptly. If no value is provided, the tool will calculate one based on the number of points and their coordinates.

  • Only the points or portions of a line that fall within the neighborhood are considered in calculating density. If no points or line sections fall within the neighborhood of a particular cell, that density of that cell will be zero.

Syntax

CalculateDensity(inputPointOrLineFeatures, outputName, {countField}, {searchDistance}, {outputAreaUnits}, {outputCellSize})
ParameterExplanationData Type
inputPointOrLineFeatures

The input point or line features that will be used to calculate the density raster.

Featureset
outputName

The name of the output raster service.

The default name is based on the tool name and the input layer name. If the layer already exists, you will be prompted to provide another name.

String
countField
(Optional)

Provide a field indicating the number of incidents at each location. For example, if you are making a population density raster, and the input points are cities, it would be appropriate to use the population of the city for the count field so cities with larger populations have more impact on the density calculations.

Field
searchDistance
(Optional)

Choose the search distance and units for the distance. When calculating the density at a cell, all features within this distance will be used in the density calculation for that cell.

The units can be in Kilometers, Meters, Miles, or Feet.

The default units are Meters.

Linear Unit
outputAreaUnits
(Optional)

Choose the area units. Density is count divided by area, and this parameter sets the units of the area in the density calculation.

  • SQUARE_METERSCalculate the density per square meter.
  • SQUARE_KILOMETERSCalculate the density per square kilometer.
  • SQUARE_FEETCalculate the density per square foot.
  • SQUARE_MILESCalculate the density per square mile.
String
outputCellSize
(Optional)

Set the cell size and units for the output raster.

The units can be in Kilometers, Meters, Miles, or Feet.

The default units are Meters.

Linear Unit

Derived Output

NameExplanationData Type
outputRaster

The output raster.

Raster Layer

Code sample

CalculateDensity example 1 (Python window)

This example creates a density image service raster from points with a population field.

import arcpy

arcpy.CalculateDensity_ra('https://MyPortal.esri.com/server/rest/services/Hosted/myPoints/FeatureServer/0',
                          'outImgServ', 'Population','150000 Meters', 'Square Kilometers','10000 Meters')
CalculateDensity example 2 (stand-alone script)

This example creates a density image service raster from points with a population field.

#-------------------------------------------------------------------------------
# Name: CalculateDensity_example02.py
# Description: Creates a density image service raster from points with a population.
#
# Requirements: ArcGIS Image Server

# Import system modules
import arcpy

# Set local variables
inPoints = 'https://MyPortal.esri.com/server/rest/services/Hosted/myPoints/FeatureServer/0'
outRaster = 'outImgServ'
inField = 'Population'
searchDistance = '150000 Meters'
areaUnit = 'Square Kilometers'
outCellSize = '10000 Meters'

# Execute CalculateDensity
arcpy.CalculateDensity_ra(inPoints, outRaster, inField, searchDistance, areaUnit, outCellSize)

Licensing information

  • Basic: Requires ArcGIS Image Server
  • Standard: Requires ArcGIS Image Server
  • Advanced: Requires ArcGIS Image Server

Related topics