Calculate Density (Raster Analysis)

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

  • This raster analysis portal tool is available when you are signed in to an ArcGIS Enterprise Link to Understanding analysis in ArcGIS Enterprise portal that has an ArcGIS Image Server Link to What is ArcGIS Image Server configured for Raster Analysis Link to Configure and deploy raster analytics. When the tool is invoked, ArcGIS Pro serves as a client and the processing happens in the servers federated with ArcGIS Enterprise. The portal tool accepts layers from your portal as input and creates output in your portal.

    The input feature layer can be a layer from the portal. It can also be a URI or URL to a feature service. While you can use local feature data and layers as input to this portal tool, best practice is to use layers from your portal as input.

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

Feature Set
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 of a cell, all features within this distance will be used in the density calculation for that cell.

The units can be 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 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