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

Description

The CalculateImageServiceField operation calculates the value of a field for an image collection. The value is calculated using the provided SQL or Arcade expression. The calculation can only be applied to one field per request; the field must already exist and must be editable. Existing field values will be overwritten.

For Arcade calculations, field names must be prefixed with $feature., such as $feature.fieldname. The CalculateImageServiceField operation's arcade expressions use the Field Calculation Arcade profile. An Arcade profile is a context in which an Arcade expression is evaluated and understood. When an Arcade expression is evaluated, the return value is cast to the field type of the output value.

The CalculateImageServiceField operation should be used when you want to add, modify, or remove information from an image collection.

Request parameters

ParameterDetails

imageCollection

(Required)

This is the output image collection (mosaic dataset) name or url. The image service must exist before you perform calculate field operations.

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>"}

field

(Required)

The field that will be updated with the new calculation.

Syntax: A String (field name) that needs to be calculated.

Example:

Use dark colors for code blocksCopy
1
field=AquisitionDate

expression

(Required)

A simple calculation expression to create a value that will populate the selected rows.

Syntax: A JSON object representing the expression to be applied

Example:

Use dark colors for code blocksCopy
1
2
expression={"expression": "CURRENT_TIMESTAMP()"}
expression={"expression": "DateOnly()"}

expressionType

(Required)

Specifies the type of expression that will be used. When set as ARCADE, an Arcade expression will be used. When set as SQL, a SQL expression will be used. The default value is ARCADE.

Values: ARCADE | SQL

context

(Optional)

Defines the mosaic dataset's properties:

  • allowedMosaicMethods: Specifies the rules for displaying overlapping imagery.
  • defaultMosaicMethods: Specifies the mosaic method that is used for views. The default mosaic method must be set in the list of values used for the allowedMosaicMethods property (listed above) or be set in the mosaic dataset's allowedMosaicMethods property.
  • orderField: The field that is used when ordering rasters using the byAttribute property of defaultMosaicMethods. The list of available fields are defined as those in the attribute table that are an integer and are of the metadata type. If the field is a numeric or date field, the orderBase property must be defined. This parameter is not needed if the By attribute value is not part of the Allowed Mosaic Methods list.
  • orderBase: Sorts the rasters based on their difference from this value in the field selected for the orderField parameter. This parameter is required only if the byAttribute property was specified for allowedMosaicMethods.
  • sortingOrder: Specifies whether the rasters will be sorted in an ascending or a descending order. This parameter is required only if the byAttribute property was specified for allowedMosaicMethods.
  • allowedTransmissionField: The fields in the attribute table that clients can view.
  • useTime: Specifies whether the mosaic dataset will be time aware. If time is activated, the start and end fields and the time format must be specified.
  • startTimeField: The field in the attribute table that shows the start time.
  • endTimeField: The field in the attribute table that shows the end time.
  • timeFormat: Specifies the time format that will be used for the mosaic dataset for the startTimeField and *endTimeField properties.
  • timeInterval: The duration of each time step interval. The time step interval defines the granularity of the temporal data. The unit of time is specified in the timeIntervalUnits parameter.
  • timeIntervalUnits: Specifies the measurement unit that is used for the time interval.

f

The response format. The default format is html.

Values: html | json | pjson

Example usage

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

Use dark colors for code blocksCopy
1
https://organization.example.com/<context>/rest/services/System/RasterAnalysisTools/GPServer/CalculateImageServiceField/submitJob?imageCollection={"itemId":"a0be5da72d534a7bb8860c026afa6e61"}&field=SensorName&expression={"expression":"Split($feature.Name, '_')[0]"}&expressionType=ARCADE&context={"allowedTransmissionField": ["Name", "MinPS", "MaxPS", "LowPS", "HighPS", "Tag", "GroupName", "ProductName", "CenterX", "CenterY", "ZOrder", "Shape_Length", "Shape_Area", "SensorName"]}&f=pjson

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.