This tutorial will show you how to add columns to attribute tables in ArcGIS. You will also learn how to compute field values as well as geometric properties of features. This tutorial was created using ArcGIS Pro version 3.3.
Before starting this tutorial, you will need to download and install a dataset following these instructions:
Create a folder called table_operations under your course working directory (e.g. C:\Users\jdoe\Documents\ArcGISPro_tutorials\table_operations\)
Download the data for this exercise then extract the contents of attribute_tables.zip into your newly created table_operations folder.
Open the tables.aprx file by double-clicking it.
The map project consists of New York counties and their unemployment rates for 2022 and 2023.
In the Contents pane, right-click on the Unemployment layer and select Attribute Table.
This should open the layer's attribute table in a new pane. The table consists of:
Name
Unemployment Rate 2023
Unemployment Rate 2022
In the next step, you will create a new field (i.e. column).
Click on the Add button in the upper left-hand corner of the attribute table pane.
This will bring up a new tab, Fields: Unemployment, listing all the field names and their properties. For example, the table indicates that the County field stores data as Text values.
At the bottom of the Fields table, you will see a new row with a green block to its left. The green block indicates that this is a new field being added to the attribute table. ArcGIS assigns the default name of Field and data type of Long to this new field. Next, we will change the field name and data type.
Rename the new column Change and change the data type to Float (this column will be used to calculate the difference in rates between 2022 and 2023).
Tip: to move across the columns, click the Tab key
To make the changes permanent, click on Save under the Fields tab in the ribbon.
Notes:
Once you've saved the changes to the attribute table, you cannot modify the field name or its data type.
If you do not save the changes to the attribute table, the newly created field will not be available in the attribute table.
In this next step, you will calculate the change in unemployment rates between 2022 and 2023.
Switch back to the Unemployment attribute table.
The Change field should be present. If it's not, you may have forgotten to save the changes in the previous step.
Depending on the spatial file format used, the default values for a newly created field will differ. A new column's values are set to <Null> by default.
Right-click on the Change header and select Calculate Field.
This should open a Calculate Field window.
The field calculator can make use of different scripting languages to write out the desired expression. Each language will have a different syntax. Here, ArcGIS defaults to Python. The other scripting language you can use is Arcade. In this example, we will switch the desired scripting language to Arcade.
In the Expression Type field, select Arcade.
Next, you will construct the expression where you will subtract the unemployment rate of 2023 from that of 2022.
In the Fields box, double-click on Unemployment Rate 2023. This will add the field name to the expression box.
Note that you could have also manually typed the expression $feature.urate_23 in the expression box.
In doing so, ArcGIS will automatically apply the Arcade syntax to the field name. Had you used Python, the syntax would have looked like !urate_23! (Note the exclamation marks wrapping the column name).
Using the pre-defined operator button, - , and field name, you will complete the expression as follows:
$feature.urate_23 - $feature.urate_22
Click OK to calculate the new values.
You should now see the newly calculated values in the attribute table.
Note that once you've computed the values you cannot undo the changes. Calculations are permanent.
In this next step, you will compute the surface area of each polygon as well as each polygon's centroid coordinate values. You will first create three new columns.
Following instructions shown earlier in this tutorial, you will create three new fields: Area, x_coord and y_coord. All three fields are float data types. Note that you can add multiple fields by clicking on the "Click here to add a new field" link at the bottom of the Fields pane.
Don't forget to save the changes to make these fields available in the attribute table!
Next, switch back to the attribute table and right-click on the Area field and select Calculate Geometry.
This should bring up the Calculate Geometry window.
Note that the Calculate Geometry window allows you to compute spatial properties for multiple fields in an attribute table. We will take advantage of this by computing all three spatial fields in a single geoprocess.
For each newly created field, select the appropriate geometric property. Here, we'll assign Area (geodesic) to the Area field, Centroid x-coordinate to the x_coord field, and Centroid y-coordinate for the y_coord field.
We'll also set the output area unit to square kilometers.
Click OK.
The newly computed spatial values should now populate the three geometric fields.
Note that spatial properties are sensitive to map projections used. By default, this tool adopts the coordinate system associated with the input data layer when calculating area. If you are adopting a coordinate system that does a poor job in preserving area, you should select Area (geodesic) option for area measurement. To learn more about coordinate systems and spatial properties, we will explore the Tissot indicatrix tutorial in the coming weeks.
This completes this in-class tutorial. You do not need to submit anything on Brightspace