Aggregate Points

AggregatePoints

This Aggregate Points task works with a layer of point features and a layer of areas. The layer of areas can be an input polygon layer or it can be square or hexagonal bins calculated when the task is run. The tool first determines which points fall within each specified area. After determining this point-in-area spatial relationship, statistics about all points in the area are calculated and assigned to the area. The most basic statistic is the count of the number of points within the area, but you can get other statistics as well.

For example, suppose you have point features of coffee shop locations and area features of counties, and you want to summarize coffee sales by county. Assuming the coffee shops have a TOTAL_SALES attribute, you can get the sum of all TOTAL_SALES within each county, the minimum or maximum TOTAL_SALES within each county, or other statistics like the count, range, standard deviation, and variance.

This tool can also work on data that is time-enabled. If time is enabled on the input points, then the time slicing options are available. Time slicing allows you to calculate the point-in area relationship while looking at a specific slice in time. For example, you could look at hourly intervals, which would result in outputs for each hour.

For an example with time, suppose you had point features of every transaction made at a coffee shop location and no area layer. The data has been recorded over a year, and each transaction has a location and a time stamp. Assuming each transaction has a TOTAL_SALES attribute, you can get the sum of all TOTAL SALES within the space and time of interest. If these transactions are for a single city, we could generate areas that are one kilometer grids, and look at weekly time slices to summarize the transactions in both time and space.

Request URL

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

Request parameters

Parameter

Description

pointLayer

(Required)

The point features that will be aggregated into the polygons in the polygonLayer or bins of the specified binSize.

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

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.

binType

The type of bin that will be generated and points will be aggregated into. Bin options are as follows:

  • Hexagon.
  • Square—This is the default.

Example: "binType" : "Hexagon"

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. Either binType or polygonLayer must be specified. If binType is chosen, then binSize and binSizeUnit specifying the size of the bins must be included.

binSize

(Required if binType is used)

The distance for the bins of type binType that the pointLayer will be aggregated into. 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 if binSize is used)

The distance unit for the bins that the pointLayer will be aggregated into.

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

Example: "binSizeUnit" : "Miles"

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. Either binType or polygonLayer must be specified. If binType is chosen, then binSize and binSizeUnit specifying the size of the bins must be included.

polygonLayer

(Required if binType is not used)

The polygon features (areas) into which the input points will be aggregated.

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

One of polygonLayer or bins binSize and binSizeUnit is required.

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

summaryFields

A list of field names and statistical summary types that you want to calculate for all points within each polygon or bin. Note that the count of points within each polygon is always returned. By default, all statistics are returned.

Syntax: [{"statisticType" : "<statistic type>", "onStatisticField" : "<field name>" }, ...]

fieldName is the name of the fields found in the input point layer.

statisticType is one of the following for numeric fields:

  • Count—Totals the number of values of all the points in each polygon.
  • Sum—Adds the total value of all the points in each polygon.
  • Mean—Calculates the average of all the points in each polygon.
  • Min—Finds the smallest value of all the points in each polygon.
  • Max—Finds the largest value of all the points in each polygon.
  • Range—Finds the difference between the Min and Max values.
  • Stddev—Finds the standard deviation of all the points in each polygon.
  • Var—Finds the variance of all the points in each polygon.

statisticType is one of the following for string fields:

  • Count—Totals the number of strings for all the points in each polygon.
  • Any—Returns a sample string of a point in each polygon.

Examples:

  • "summaryFields" : [{"statisticType" : "Mean", "onStatisticField" : "Annual_Sales"},{"statisticType": "Sum", "onStatisticField": "Annual_Sales"}]
  • Only return count: "summaryFields" : []

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.

Syntax:
{
"extent" : {extent},
"processSR" : {spatial reference},
"outSR" : {spatial reference},
"dataStore":{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>/AggregatePoints/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>/AggregatePoints/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 inputPoints.

The layer will inherit all the attributes of the input polygon layer; will have a Count attribute, which is the number of points that are enclosed by the polygon; and by default, will calculate all statistics for each field in the pointsLayer.

If a summaryFields parameter is specified in the task request, the layer will compute the anything specified in the summaryFields. For example, if you had requested:

"summaryFields" :[{"statisticType": "Mean", "fieldName": "Annual_Sales"],

the resulting polygon features would have two attributes, Count and mean_Annual_Sales, to contain the calculated values.

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