Calculate Density

URL:
https://<geoanalytics-url>/CalculateDensity
Methods:
GET
Version Introduced:
10.5

Description

Calculate Density

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

For point input, each point represent s the location of an 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.

Other use cases for this tool include the following:

  • Create crime density maps to help police departments properly allocate resources to high crime areas.
  • Calculate densities of hospitals within a country. The result layer will show areas with high and low accessibility to hospitals.This information can be used to determine where new hospitals should be built.
  • Identify areas that are at high risk of forest fires based on historical locations of forest fires.
  • Locate communities that are far from major highways to plan where new roads should be constructed.

Request parameters

ParameterDetails

inputLayer (Required)

The point layer on which the density will be calculated.

Syntax: As described in Feature input, this parameter can be one of the following:

  • A URL to a feature service layer with an optional filter to select specific features
  • A URL to a big data catalog service layer with an optional filter to select specific features
  • A feature collection

REST examples

Use dark colors for code blocksCopy
1
2
3
4
//REST web example
{"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}
//REST scripting example
"inputLayer": {"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}

fields (Optional)

Provides one or more fields specifying the number of incidents at each location. You can calculate the density for multiple fields, and the count of points will always have the density calculated.

REST examples

Use dark colors for code blocksCopy
1
2
3
4
//REST web example
crimeRate, indicator
//REST scripting example
"fields": "crimeRate, indicator"

weight (Required)

The type of weighting applied to density calculations. This parameter supports two values: Uniform(default), which calculates a magnitude-per-area, and Kernel, which applies a kernel function to fit a smooth tapered surface to each point.

Values: Uniform| Kernel

REST examples

Use dark colors for code blocksCopy
1
2
3
4
//REST web example
Uniform
//REST scripting example
"weight": "Kernel"

binType (Required)

The type of bin used to calculate density.

Analysis using Square or Hexagon bins requires a projected coordinate system. When aggregating layers into bins, the input layer or processing extent (processSR ) must have a projected coordinate system. If a projected coordinate system is not specified when running analysis, a projection will be picked based on the extent of the data.

Values: Hexagon| Square

REST examples

Use dark colors for code blocksCopy
1
2
3
4
//REST web example
Hexagon
//REST scripting example
"binType": "Hexagon"

binSize (Required)

The distance for the bins that the inputLayerwill be analyzed using. When generating bins for the Squarebin type, the number and units specified determine the height and length of the square. For the Hexagonbin type, the number and units specified determine the distance between parallel sides.

REST examples

Use dark colors for code blocksCopy
1
2
3
4
//REST web example
108.3
//REST scripting example
"binSize": 100

binSizeUnit (Required)

The distance unit for the bins for which the density will be calculated and t he linear unit to be used with the value specified for binSize. The default is Meters.

Values: Meters | Kilometers | Feet | FeetInt | FeetUS | Miles |MilesInt | MilesUS | NauticalMiles | NauticalMilesInt | NauticalMilesUS | Yards | YardsInt | YardsUS

REST examples

Use dark colors for code blocksCopy
1
2
3
4
//REST web example
Meters
//REST scripting example
"binSizeUnit": "Miles"

timeStepInterval (Optional)

A numeric value that specifies duration of the time step interval. The default is none. This option is only available if the input points are time enabled and represent an instant in time.

REST examples

Use dark colors for code blocksCopy
1
2
3
4
//REST web example
20
//REST scripting example
"timeStepInterval": 20

timeStepIntervalUnit (Optional)

A string that specifies units of the time step interval. The default is none. This option is only available if the input points are time enabled and represent an instant in time.

Values: Milliseconds | Seconds | Minutes | Hours | Days | Weeks | Months | Years

REST examples

Use dark colors for code blocksCopy
1
2
3
4
//REST web example
Days
//REST scripting example
"timeStepIntervalUnit": "Days"

timeStepRepeatInterval (Optional)

A numeric value that specifies how often the time step repeat occurs. The default is none. This option is only available if the input points are time enabled and of time type instant.

REST examples

Use dark colors for code blocksCopy
1
2
3
4
//REST web example
2
//REST scripting example
"timeStepRepeatInterval": 2

timeStepRepeatIntervalUnit (Optional)

A string that specifies units of the time step interval. The default is none. This option is only available if the input points are time enabled and represent an instant in time.

REST examples

Use dark colors for code blocksCopy
1
2
3
4
//REST web example
Minutes
//REST scripting example
"timeStepRepeatIntervalUnit": "Minutes"

timeStepReference (Optional)

A date that specifies the reference time to align the time slices to, represented in milliseconds from epoch. The default is January 1, 1970, at 12:00 a.m. (epoch time stamp 0). This option is only available if the input points are time enabled and of time type instant.

REST examples

Use dark colors for code blocksCopy
1
2
3
4
//REST web example
946684800000
//REST scripting example
"timeStepReference": 946684800000

radius (Required)

The size of the neighborhood within which density will be calculated. The radius size must be larger than the binSizevalue.

REST examples

Use dark colors for code blocksCopy
1
2
3
4
//REST web example
100
//REST scripting example
"radius": "100"

radiusUnit (Required)

The distance unit for the radius defining the neighborhood for which density will be calculated and t he linear unit to be used with the value specified for binSize. The default is Meters.

Values: Meters | Kilometers | Feet | FeetInt | FeetUS | Miles |MilesInt | MilesUS | NauticalMiles | NauticalMilesInt | NauticalMilesUS | Yards | YardsInt | YardsUS

REST examples

Use dark colors for code blocksCopy
1
2
3
4
//REST web example
Miles
//REST scripting example
"radiusUnit": "Miles"

areaUnits (Optional)

The output units of the density values. The default value is SquareKilometers. If density values are very small, you can increase the size of the area units (for example, square meters to square kilometers) to return larger values. This value only scales the result.

Values: SquareMeters| SquareKilometers| Hectares| SquareFeet|SquareFeetInt| SquareFeetUS|SquareYards|SquareYardsInt| SquareYardsUS| SquareMiles| SquareMilesInt| SquareMilesUS| Acres| AcresInt| AcresUS

REST examples

Use dark colors for code blocksCopy
1
2
3
4
//REST web example
SquareMiles
//REST scripting example
"areaUnits": "SquareKilometers"

outputName (Required)

The task will create a feature service of the results. You define the name of the service.

REST examples

Use dark colors for code blocksCopy
1
2
3
4
//REST web example
myOutput
//REST scripting example
"outputName": "myOutput"

context (Optional)

The context parameter contains additional settings that affect task execution. For this task, there are four settings:

  • Extent (extent )—A bounding box that defines the analysis area. Only those features that intersect the bounding box will be analyzed.
  • Processing spatial reference (processSR )—The features will be projected into this coordinate system for analysis.
  • Output spatial reference (outSR )—The features will be projected into this coordinate system after the analysis to be saved. The output spatial reference for the spatiotemporal big data store is always WGS84.
  • Data store (dataStore )—Results will be saved to the specified data store. The default is the spatiotemporal big data store.

Syntax:

Use dark colors for code blocksCopy
1
2
3
4
5
6
{
  "extent": {extent},
  "processSR": {spatial reference},
  "outSR": {spatial reference},
  "dataStore": {data store}
}

f

The response format. The default response format is html .

Values: html | json | pjson

Example usage

The example below is a sample request URL for CalculateDensity:

Use dark colors for code blocksCopy
1
https://webadaptor.domain.com/server/rest/services/System/GeoAnalyticsTools/GPServer/CalculateDensity/submitJob?inputLayer={"url":"https://webadaptor.domain.com/server/rest/services/Hurricane/hurricaneTrack/0"&bintype=Hexagon&binSize=108.3&binSizeUnit=Meters&fields="classed_magnitude"&weight=Uniform&timeStepInterval=20&timeStepIntervalUnit=Minutes&timeStepRepeatInterval=1&timeStepRepeatIntervalUnit=Days&timeStepReference=946684800000&radius=10&radiusUnit=NauticalMiles&areaUnits=SquareMiles&outputName=myOutput&context={"extent":{"xmin":-122.68,"ymin":45.53,"xmax":-122.45,"ymax":45.6,"spatialReference":{"wkid":4326}}}&f=json

Response

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

Syntax:

Use dark colors for code blocksCopy
1
2
3
4
{
  "jobId": "<unique job identifier>",
  "jobStatus": "<job status>"
}

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

Use dark colors for code blocksCopy
1
https://<analysis url>/CalculateDensity/jobs/<jobId>

Access results

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

Use dark colors for code blocksCopy
1
https://<analysis-url>/CalculateDensity/jobs/<jobId>/results/output?token=<your token>&f=json
ResponseDescription

output

The outputvalue will always contain polygon features. The number of resulting polygons is based on the location of the inputLayervalue. The layer will have an attribute for each field on which the density has been calculated, as well as the density of the count of points.

Use dark colors for code blocksCopy
1
{"url": "https://<analysis-url>/CalculateDensity/jobs/<jobId>/results/output"}

The result has properties for parameter name, data type, and value. The contents of value depend on the outputName parameter provided in the initial request. The value contains the URL of the feature service layer.

Use dark colors for code blocksCopy
1
2
3
4
5
{
  "paramName": "output",
  "dataType": "GPRecordSet",
  "value":{"url": "<hosted featureservice layer url>"}
}

See Feature output for more information about how the result layer is accessed.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.