Skip To Content
ArcGIS Developers

Calculate Density

Calculate Density

The Calculate Density task 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.

For point input, each point should represent the location of some event or incident, and the result layer represents a count of the incident per unit area. A higher density value in a new location means that there are more points near that location. In many cases, the result layer can be interpreted as a risk surface for future events. For example, if the input points represent locations of lightning strikes, the result layer can be interpreted as a risk surface for future lightning strikes.

For line input, the line density surface represents the total amount of line that is near each location. The units of the calculated density values are the length of line per unit area. For example, if the lines represent rivers, the result layer will represent the total length of rivers that are within the search radius. This result can be used to identify areas that are hospitable to grazing animals.

Other use cases of this tool include the following:

  • Creating crime density maps to help police departments properly allocate resources to high crime areas.
  • Calculating densities of hospitals within a county. The result layer will show areas with high and low accessibility to hospitals, and this information can be used to decide where new hospitals should be built.
  • Identifying areas that are at high risk of forest fires based on historical locations of forest fires.
  • Locating communities that are far from major highways in order to plan where new roads should be constructed.

Request URL

http://<analysis url>/CalculateDensity/submitJob

Request Parameters




The point or line features from which to calculate density.

Syntax: As described in detail in the Feature Input topic, this parameter can be

  • a URL to a feature service layer with an optional filter to select specific features, or
  • a feature collection.


  • {"url": <feature service layer url>, "filter": <where clause>}
  • {"layerDefinition": {}, "featureSet": {}, "filter": <where clause>}


A field specifying the number of incidents at each location. For example, if you have points that represent cities, you can use a field representing the population of the city as the count field, and the resulting population density layer will calculate larger population densities near cities with larger populations.

If not specified, each location will be assumed to represent a single count.


This value is used to create a mesh of points where density values are calculated. The default is approximately 1/1000th of the smaller of the width and height of the analysis extent as defined in the context parameter. The smaller the value, the smoother the polygon boundaries will be. Conversely, with larger values, the polygon boundaries will be more coarse and jagged.


The units of the cellSize value. You must provide a value if cellSize has been set.

Values: Miles | Feet | Kilometers | Meters

Example: "cellSizeUnits": "Meters"


A distance specifying how far to search to find point or line features when calculating density values. For example, if you provide a search distance of 10,000 meters, the density of any location in the output layer is calculated based on features that are within 10,000 meters of the location. Any location that does not have any incidents within 10,000 meters will receive a density value of zero.

If no distance is provided, a default will be calculated that is based on the locations of the input features and the values in the count field (if a count field is provided).

Example: "radius": "10"


The units of the radius parameter. You must provide a value if radius has been set.

Values: Miles | Feet | Kilometers | Meters

The default is based on the units specified in your profile and will be either Miles or Kilometers.

Example: "radiusUnits": "Kilometers"


A layer specifying the polygon(s) where you want densities to be calculated. For example, if you are interpolating densities of fish within a lake, you can use the boundary of the lake in this parameter and the output will only draw within the boundary of the lake.

Syntax: As described in detail in the Feature Input topic, this parameter can be

  • a URL to a feature service layer with an optional filter to select specific features, or
  • a feature collection.


The units of the calculated density values.

Values: SquareMiles | SquareKilometers

The default is based on the units specified in your profile and will be either SquareMiles or SquareKilometers.

Example: "areaUnits": "SquareMiles"


Determines how density values will be classified into polygons.


  • EqualInterval—Polygons are created such that the range of density values is equal for each area.
  • GeometricInterval—Polygons are based on class intervals that have a geometric series. This method ensures that each class range has approximately the same number of values within each class and that the change between intervals is consistent.
  • NaturalBreaks—Class intervals for polygons are based on natural groupings of the data. Class break values are identified that best group similar values and that maximize the differences between classes.
  • EqualArea—Polygons are created such that the size of each area is equal. For example, if the result has more high density values than low density values, more polygons will be created for high densities.
  • StandardDeviation—Polygons are created based upon the standard deviation of the predicted density values.

The default is EqualInterval.

Example: "classificationType": "NaturalBreaks"


This value is used to divide the range of predicted values into distinct classes. The range of values in each class is determined by the classificationType parameter. Each class defines the boundaries of the result polygons.

The default is 10. The maximum is 32.

Example: "numClasses": "15"


If provided, the task will create a feature service of the results. You define the name of the service. If outputName is not supplied, the task will return a feature collection.

  "serviceProperties": {
    "name": "<service name>"


Context contains additional settings that affect task execution. For Calculate Density, there are two settings.

  1. Extent (extent)—a bounding box that defines the analysis area. Only those points in the input inputLayer that intersect the bounding box will be analyzed.
  2. Output Spatial Reference (outSR)—the output features will be projected into the output spatial reference.

"extent" : {extent}
"outSR" : {spatial reference}


The response format. The default response format is html.

Values: html | json


When you submit a request, the service assigns a unique job ID for the transaction.

"jobId": "<unique job identifier>",
"jobStatus": "<job status>"

After the initial request is submitted you can use the jobId to periodically check the status of the job and messages as described in the topic Checking job status. Once the job has successfully completed, you use the jobId to retrive the results. To track the status, you can make a request of the following form:

http://<analysis url>/CalculateDensity/jobs/<jobId>

Accessing results

When the status of the job request is esriJobSucceded, you can access the results of the analysis by making a request of the following form:

http://<analysis url>/CalculateDensity/jobs/<jobId>/results/<output parameter name>?token=<your token>&f=json



The polygon features representing density. Each polygon will surround predicted values based on the classificationType and numClasses.

The result has the following fields, where <unit> is based on the areaUnits parameter, and will either be SquareMile or SquareKilometer:

  • Value_Min_per_<unit>—the minimum density value of the polygon.
  • Value_Max_per_<unit>—the maximum density value of the polygon
  • AnalysisArea—the area of the polygon in areaUnits.

Request example:
"http://<analysis url>/CalculateDensity/jobs/<jobId>/results/resultLayer"}

The result has properties for parameter name, data type, and value. The contents of value depends upon the outputName parameter provided in the initial request.

  • If outputName was provided, value contains the url to the feature service layer.
    "value":{"url":"<hosted featureservice layer url>"}
  • If outputName was not provided, value contains a feature collection.
    "value":{"layerDefinition": {}, "featureSet": {}  }

See Feature Output for more information about how the result layer or collection is accessed.