Summary
In ArcGIS Pro, it possible to populate a field with a portion of the values from a different field. For example, if the field value is 'house_name' or 'country_name', the new field can be populated with 'house' or 'country', respectively. This article describes the workflow to extract characters from a string field and populate them in a different field using the Calculate Field tool in ArcGIS Pro.
Procedure
- In ArcGIS Pro, on the top ribbon, click Analysis >Tools.
- In the Geoprocessing pane, search for the Calculate Field tool.
- In the Calculate Field tool pane, under Parameters, select the layer for the Input Table. In this example, 'malaysia_highway' is selected.
- Select an existing field or create a new field for Field Name (Existing or New). Move to Step 6 if an existing field is selected.
- For the newly created field, for Field Type, select the Text data type. Refer to ArcGIS Pro: ArcGIS field data types for more information.
- For Expression Type, select Python 3.
- In the Expression text box above the code block, enter one of the three scripts described below.
Note:
An array starts from zero (0) as the first position.
- Use this script to allow multiple characters to be extracted within the specified range.
!Field_Name![X:Y]
- Use this script to extract a character from a specific position from the left.
!Field_Name![X]
- Use this script to extract a character from a specific position from the right.
!Field_Name![-X]
- Click Run.