Calculate Density

Calculate Density

The Calculate Density task creates a density map from point features by spreading known quantities of some 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 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.

Other use cases of this tool include the following:

Request URL

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

Request parameters

Parameter

Description

inputLayer

(Required)

The point layer on which the density will be calculated.

Syntax: As described in detail in the Feature input topic, 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

Examples:

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

Analysis using square or hexagon bins requires a projected coordinate system. When aggregating layers into bins, it is required that the input layer or processing extent (processSR) has a projected coordinate system. At 10.5.1, if a projected coordinate system is not specified when running analysis the World Cylindrical Equal Area (wkid 54034) projection will be used.

fields

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

Example: "fields": "crimeRate, indicator"

weight

(Required)

The type of weighting applied to the density calculation. There are two options:

  • Uniform—Calculates a magnitude-per-area. This is the default.
  • Kernel—Applies a kernel function to fit a smooth tapered surface to each point.

Example: "weight": "Kernel"

binType

(Required)

The type of bin used to calculate density. Bin options are:

  • Hexagon
  • Square

Example: "binType": "Hexagon"

binSize

(Required)

The distance for the bins that the inputLayer will be analyzed using. When generating bins, for Square, the number and units specified determine the height and length of the square. For Hexagon, the number and units specified determine the distance between parallel sides.

Example: "binSize": 100

binSizeUnit

(Required)

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

Values: Meters | Kilometers | Feet | Miles | NauticalMiles | Yards

Example: "binSizeUnit" : "Miles"

radius

(Required)

The size of the neighborhood within which to calculate the density. The radius size must be larger than the binSize.

Example: "radius": 100

radiusUnit

(Required)

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

Values: Meters | Kilometers | Feet | Miles | NauticalMiles | Yards

Example: "radiusUnit" : "Miles"

timeStepInterval

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.

Example: "timeStepInterval": 20

timeStepIntervalUnit

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

Example: "timeStepIntervalUnit" : "Minutes"

timeStepRepeatInterval

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.

Example: "timeStepRepeatInterval" : 1

timeStepRepeatIntervalUnit

A string that specifies the temporal unit of the step repeat. The default is none. This option is only available if the input points are time-enabled and of time type instant.

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

Example: "timeStepRepeatIntervalUnit" : "Hours"

timeStepReference

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.

Example: "timeStepReference" : 946684800000

areaUnits

The desired output units of the density values. By default, this is set to 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. Possible area units are:

  • SquareMeters
  • SquareKilometers
  • Hectares
  • SquareFeet
  • SquareYards
  • SquareMiles
  • Acres

Example: "areaUnits" : "SquareKilometers"

outputName

(Required)

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

Example: "outputName" : "myOutput"

context

Context contains additional settings that affect task execution. For this task, there are three 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.

f

The response format. The default response format is html.

Values: html | json

Response

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

Syntax:
{
"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 Checking job status. Once the job has successfully completed, use the jobId to retrieve 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 esriJobSucceeded, you can access the results of the analysis by making a request of the following form:

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

Parameter

Description

output

output will always contain polygon features. The number of resulting polygons is based on the location of inputLayer.

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.

Request example:
{"url": 
"http://<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.

{
"paramName":"output", 
"dataType":"GPRecordSet",
"value":{"url":"<hosted featureservice layer url>"}
}

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

9/13/2017