The Field Calculator task updates values in one or more fields based on an expression you provide. The fields to update can be existing fields or a new fields that you create as part of the task request. The expression can use values from other fields. The result of this task is a new layer with all the fields from the input layer as well as any new fields you create. Field values are updated according to the expressions you provide.
Request URL
http://<analysis url>/FieldCalculator/submitJob
Request parameters
Parameter | Description |
---|---|
(Required) | The layer containing the field to be updated. The layer can be one of the following:
Examples:
If a |
(Required) | A list of fields and expressions. The general form is as follows:
Field
To update an existing field, supply the name of the field in
To create a new field, supply the following in the
Example: add a new field named
Expression
To use the value of an existing field in an expression, surround the field name with exclamation points. For example, to calculate a population density value based on the value of the field
Python is used to interpret expressions. The Field Calculator task uses the ArcGIS geoprocessing tool Calculate Field to perform all calculations. For more examples of expressions, see the Calculate Field tool reference documentation. As you read this tool reference page, keep the following in mind:
Working with strings When assigning strings to text fields, values must be in single quotation marks. For example, to assign the string VACANT to a field, use the following: Example: Create a field named
You can use Python string functions on field values. For example, to uppercase values in the field
Working with numbers
Functions in Python's The math module provides number-theoretic and representation functions, power and logarithmic functions, trigonometric functions, angular conversion functions, hyperbolic functions, and mathematical constants. To learn more about the math module, see the Python help.
Working with dates
Functions in Python's
The syntax for date and time constants is
Working with geometries
As shown in the Calculate Field documentation, you can access properties of feature geometry, including Expressions can use the geometry
|
|
If provided, the task will create a feature service of the results. You define the name of the service. If an Syntax:
In ArcGIS Online or ArcGIS Enterprise 10.9.1 and later, you can overwrite an existing feature service by providing the Syntax:
or
|
| Context contains additional settings that affect task execution. For Field Calculator, there are two settings.
Syntax:
|
| The response format. The default response format is Values: |
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 the job
to periodically check the status of the job and messages as described in the Check job status topic. Once the job has successfully completed, use the job
to retrieve the results. To track the status, you can make a request of the following form:
http://<analysis url>/FieldCalculator/jobs/<jobId>
Results access
When the status of the job request is esri
, you can access the results of the analysis by making a request of the following form:
http://<analysis url>/FieldCalculator/jobs/<jobId>/results/<output parameter name>?token=<your token>&f=json
Parameter | Description |
---|---|
| Request example:
The result has properties for parameter name, data type, and value. The contents of the value depend on the
See Feature Output for more information about how the result layer or collection is accessed. |