操作方法

操作方法:在 ArcGIS Online 中使用 Arcade 表达式替换字段的值

Last Published: July 21, 2023

摘要

In ArcGIS Online, it is possible to replace values of a field using the Replace function in Field Calculator. The Replace function enables users to fix typos, edit or delete values, and rename incorrect or obsolete values for rows of a specific field in an attribute table.

In this example, all Yes values in the Mayor column are replaced with No.

Yes values in the Mayor column

过程

Follow the steps below to replace all values of a field using an Arcade expression in ArcGIS Online.

  1. In ArcGIS Online, click the desired hosted feature layer. On the item details page, click the Data tab.
Data tab in the hosted feature layer
  1. Right-click the field header and select Calculate. In this example, the Mayor field is selected.
Calculator tool for the Mayor column
  1. In the Calculate Field dialog box, click Arcade.
Arcade option in Calculate Field dialog box
  1. In the Arcade Calculator dialog box, click Functions, and type Replace in the box. Click Replace. An Arcade expression is displayed in the Expression field.
Default Arcade expression for Replace function
  1. In the Expression field, modify the Arcade expression as follows:
Replace ($feature.field, ‘initial value’, ‘final value’) 

In this example, the Replace function is used to change all ‘Yes’ values to ‘No’ in the Mayor field using the following expression:

Replace ($feature.Mayor, ‘Yes’, ‘No’)
No values in the Mayor column
  1. Click Test to verify the expression, and click OK to apply the query.
Test and verify the Arcade expression

The image below shows an example of the output in the Mayor field.

Output of Mayor column after the Arcade Replace function
Note: 
To replace all values in a field in ArcMap, refer to How To: Remove and replace characters from a field in an attribute table.

文章 ID:000022951

接收通知并查找新问题或常见问题的解决方案

从我们全新的 AI 聊天机器人中获得简明答案和视频解决方案。

下载 Esri 支持应用程序

获取来自 ArcGIS 专家的帮助

联系技术支持部门

下载 Esri 支持应用程序

转至下载选项