Skip To Content

Zonal Statistics As Table

Description

Zonal Statistics As Table diagram

The ZonalStatisticsAsTable task summarizes the cells of a raster within the boundaries of zones defined by another dataset.

ZonalStatisticsAsTable uses two layers, one that defines specific zones and another that defines the value of each location across the whole area, and calculates summary statistic for the values that fall within each particular area. The layer that defines the areas, inputZoneRasterOrFeatures, is a raster or feature dataset that defines the boundaries of each zone for which a summary values will be calculated. If the zone layer is a raster, it must have an integer data type. If the zone is a feature layer, it can contain overlapping polygons, where the zonal analysis will be performed for each individual feature. The area defining the values, inputValueRaster, is a raster dataset that records the value of a particular property at each location.

The statistic can report such properties as the sum of all the values in each area, the maximum value, or the average value. The statisticType value can be calculated based on a mathematical function, the result of a sorting operation on the values, or an indication of the frequency values.

The following are example applications of ZonalStatisticsAsTable:

  • Given a layer of state boundaries and the distribution of mean precipitation over the continental United States, calculate the state-wise distribution of extreme rain events using a list of percentile values.
  • Given a layer of overlapping ecological zones and a raster layer of soil moisture, calculate all supported statistics within each zone to relate zones with soil moisture availability.

Request parameters

ParameterDetails
inputZoneRasterOrFeatures

(Required)

The layer that defines the boundaries of the zones.

Syntax: This parameter can have either a raster input or a feature input. For raster input, this parameter can be specified as a portal item ID, a URL to a raster image service layer, a cloud raster dataset, or a shared raster dataset. For feature input, this parameter can be specified as either a URL to a feature service layer or a feature collection.

Raster input examples:

//Portal item as input raster
"inputZoneRasterOrFeatures":{"itemId": <portal item Id>}

//URL as input raster
"inputZoneRasterOrFeatures":{"url": <image service layer url>}

Feature input examples:

//Feature layer URL
"inputZoneRasterOrFeatures":{"url": <feature service layer url>}

//Feature collection
"inputZoneRasterOrFeatures":{"layerDefinition": {}, "featureSet": {}}
inputValueRaster

(Required)

The raster layer that will be summarized by the zones defined by the inputZoneRasterOrFeatures value.

Syntax: This parameter can be specified as a portal item ID, a URL to a raster image service layer, a cloud raster dataset, or a shared raster dataset.

Examples:

//Portal item as input raster to summarize
"inputValueRaster":{"itemId": <portal item Id>}

//URL as input raster to summarize
"inputValueRaster":{"url": <image service layer url>}
outputTableName

(Required)

The output table feature service name that will be created.

You can specify the name, or you can create an empty service using Portal Admin Sharing API and use the return JSON object as input to this parameter.

Syntax: A JSON object describes the name of the output or the output table.

Output name example:

"outputTableName":{"serviceProperties":{"name":"testrasteranalysis"}}

Output table examples:

//Output portal item:
"outputTableName":{"itemId": <portal item id>}

//Output url:
"outputTableName":{"url": <feature service url}

//Output table layer service:
"outputTableName":{"serviceProperties":
  {"name":"testrasteranalysis",
    "serviceUrl":"https://<server name>/server/rest/services/Hosted/testrasteranalysis/FeatureServer/0"},
  "itemProperties":{"itemId":"351fe8441a1a436d8001124487b02550","folderId":"sdfwerfbd3ec25584d0d8f4"}
}
zoneField

(Required)

A field on the inputZoneRasterOrFeatures value that contains the values that define each zone.

It can be an integer or a string field of the zone dataset.

Example:

"zoneField": ParcelID
ignoreNodata

Specify whether NoData in the raster layer to summarize will influence the results of the areas they fall within.

Syntax: A Boolean value as either true or false.

  • A value of true specifies that, within any particular area, only cells that have a value in the raster layer being summarized will be used in determining the output value for that area. Any missing or NoData cells will be ignored in the statistics calculations. This is the default.
  • A value of false specifies that, within any particular area, if any cells in the raster layer do not have a value, it is deemed that there is insufficient information to perform statistical calculations for all the cells in that zone. As a result, the entire zone will receive the NoData value on the output raster.

Example:

"ignoreNodata": true
statisticType

The statistical summary type that will be calculated for the cells within each zone of the feature in the inputValueRaster value.

Syntax: The input can be one of the following:

  • ALL—All of the statistics will be calculated for an integer type value raster. All statistics except MEDIAN and PERCENTILE will be calculated for a floating-point type value raster. This is the default.
  • MEAN—Calculates the average of all cells in the value raster that belongs to the same zone as the output cell.
  • MAJORITY—Determines the majority value of all cells in the value raster that belongs to the same zone as the output cell.
  • MAXIMUM—Determines the largest value of all cells in the value raster that belongs to the same zone as the output cell.
  • MEDIAN—Finds the median value of all cells in the value raster that belongs to the same zone as the output cell.
  • MINIMUM—Finds the smallest value of all cells in the value raster that belongs to the same zone as the output cell.
  • MINORITY—Determines the minority value of all cells in the value raster that belongs to the same zone as the output cell.
  • PERCENTILE—Calculates a percentile of all cells in the value raster that belong to the same zone as the output cell. The 90th percentile is calculated by default. You can specify other values (from 0 to 100) using the percentileValues parameter.
  • RANGE—Finds the range of all cells in the value that belongs to the same zone as the output zone.
  • SUM—Adds the total value of all cells in the value raster that belongs to the same zone as the output cell.
  • STD—Finds the standard deviation of all cells in the value raster that belongs to the same zone as the output cell.
  • VARIETY—Finds the variety of all cells in the value raster that belongs to the same zone as the output cell.
  • MIN_MAX—Calculates both the minimum and maximum statistics.
  • MEAN_STD—Calculates both the mean and standard deviation statistics.
  • MIN_MAX_MEAN—Calculates the minimum, maximum and mean statistics.

If the inputValueRaster value is floating-point type, the zonal calculations for MAJORITY, MINORITY, and VARIETY cannot be computed.

Example:

"statisticType": "MEAN"
percentileValues

Specifies the percentile value to calculate. The default is 90, for the 90th percentile.

The values can range from 0 to 100. The 0th percentile is essentially equivalent to the minimum statistic, and the 100th percentile is equivalent to the maximum. A value of 50 will produce approximately the same result as the median statistic.

This parameter is only supported if the statisticsType parameter is set to PERCENTILE or ALL.

A single or a list of double-precision floating-point values that can range from 0 to 100.

Example:

"percentileValues": [25, 55, 75]
processAsMultidimensional

Specifies how the input rasters will be processed if they are multidimensional.

Syntax: A Boolean value as either true or false.

  • A value of true specifies that statistics will be calculated for all dimensions (such as time or depth) of a multidimensional dataset.
  • A value of false specifies that statistics will be calculated from the current slice of a multidimensional dataset. This is the default.

Example:

"processasMultidimensional": true

percentileInterpolationType

Specifies the method of percentile interpolation to be used when the number of values from the input raster to be calculated is even.

  • AUTO_DETECT—If the input value raster is of integer pixel type, the NEAREST method is used. If the input value raster is of floating-point pixel type, the LINEAR method is used. This is the default.
  • NEAREST—The nearest available value to the desired percentile is used.
  • LINEAR—The weighted average of the two surrounding values from the desired percentile is used.

Example:

"percentileInterpolationType": NEAREST

calculateCircularStatistics

Specifies how the statistics type will be calculated.

Syntax: A Boolean value as either true or false.

  • A value of true specifies that the task calculates circular statistics that are appropriate for cyclic quantities, such as compass direction in degrees, times of day, and fractional parts of real numbers.
  • A value of false specifies that the task calculates arithmetic statistics. This is the default.

Example:

"calculateCircularStatistics": true

circularWrapValue

Specifies the highest possible value (upper bound) in the cyclic data. It is a positive number, with a default value of 360. This value also represents the same quantity as the lowest possible value (lower bound).

This parameter is applicable only when circular statistics are calculated.

context

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

  • Extent (extent)—A bounding box that defines the analysis area.
  • Output Spatial Reference (outSR)—The output raster will be projected into the output spatial reference.
  • Snap Raster (snapRaster)—The output raster will have its cells aligned with the specified snap raster.
  • Cell Size (cellSize)—The output raster will have the resolution specified by cell size.
  • Mask (mask)—Only cells that fall within the analysis mask will be considered in the operation.
f

The response format. The default response format is html.

Values: html | json | pjson

Response

When you submit a request, the task 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 Checking job status. Once the job has successfully completed, you use the jobId to retrieve the results. To track the status, you can make a request of the following form:

https://<raster analysis tools url>/ZonalStatisticsAsTable/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:

https://<raster analysis tools url>/ZonalStatisticsAsTable/jobs/<jobId>/results/outputTable

Example usage

The following is a sample request URL for ZonalStatisticsAsTable:

https://services.myserver.com/arcgis/rest/services/System/RasterAnalysisTools/GPServer/ZonalStatisticsAsTable/submitJob

JSON Response syntax

The response returns the outputTable output parameter, which has properties for parameter name, data type, and value. The content of value is always the output table itemId and the feature service URL.

{
  "paramName": <parameter name>,
  "dataType": "GPString",
  "value": {
    "itemId": <item Id>,
    "url": <URL>
  }
}

JSON Response example

{
  "paramName": "outputTable",
  "dataType": "GPString",
  "value": {
    "url": "https://<server name>/server/rest/services/Hosted/<service name>/FeatureServer/0",
    "itemId": "351fe8441a1a436d8001124487b02550"
  }
}

Temas relacionados