Skip to content
URL:
https://<rasteranalysistools-url>/CalculateStatistics
Methods:
GETPOST
Version Introduced:
10.7

Description

The CalculateStatistics operation calculates statistics for an existing image collection. Statistics are required for raster and mosaic datasets to perform certain tasks, such as applying a contrast stretch or classifying data.

Request parameters

ParameterDetails

imageCollection

(Required)

The output image collection (mosaic dataset) name or URL. The image service must exist before performing this operation.

Syntax: JSON object supports three keys: itemId, url and uri. They keys are case sensitive.

Example:

Use dark colors for code blocksCopy
1
2
3
      {"itemId": "<portal item id>"}
      {"url": "<image service url>"}
      {"uri": "<cloud raster uri or shared data path>"}

skipfactors

(Optional)

The number of horizontal and vertical pixels between samples. This sets the overview cell size or resolution for the operation. A skip factor controls the portion of the raster that is used when calculating the statistics. The input value indicates the horizontal or vertical skip factor, where a value of 1 will use each pixel and a value of 2 will use every second pixel. The skip factor can only range from 1 to the number of columns/rows in the raster. The default input values for the horizontal and vertical skip factor is 10.

Syntax: A JSON object describing the horizontal and vertical skip factors.

Example

Use dark colors for code blocksCopy
1
skipfactors={"x":10,"y":10}

context

(Optional)

Contains additional settings that affect task execution. This task has the following settings:

  • parallelProcessingFactor: The number of processes across which a tool will spread its operation.
  • ignoreValues: The pixel values that are not to be included in the statistics calculation. The default is Null or the last ignore value used.
  • skipExisting: Specifies whether statistics will be calculated only when they are missing or will be regenerated even if they exist. The default is true.
  • areaOfInterest: The area in the dataset that will be used to calculate statistics, so they are not generated from the entire dataset. The default is Null.

f

The response format. The default format is html.

Values: html | json | pjson

Example usage

The following is a sample request URL for the CalculateStatistics operation:

Use dark colors for code blocksCopy
1
https://organization.example.com/<context>/rest/services/System/RasterAnalysisTools/GPServer/CalculateStatistics/submitJob?imageCollection={"itemId":"51f2e556092a4e098b5d05b4b0ad94e7"}&skipfactors={"x":1,"y":1}&context={"ignoreValues":null}&f=pjson

Response

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

Syntax:

Use dark colors for code blocksCopy
1
{ "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 Check 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:

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

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://<raster analysis tools url>/CalculateStatistics/jobs/<jobId>/results/outputCollection

JSON Response example

The response returns the outputCollection output parameter, which has properties for parameter name, data type, and value. The content of the value is always the output raster dataset’s itemId and image service URL.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
{
    "paramName": "outputCollection",
    "dataType": "GPString",
    "value": [{
        "url": "https://<server url>/arcgis/rest/services/Hosted/Hosted_mosaic_image_collection/ImageServer"
    }]
}

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