Before tackling this tutorial, you will need to download and install a dataset following these instructions:
Create a folder called table_operations somewhere under your personal directory (e.g. C:\Users\jdoe\Documents\Tutorials\table_operations\).
Download the data for this exercise then extract the contents of managing_data.zip into your newly created table_operations folder.
Open the tables.aprx file by double-clicking it.
The map project consists of Maine counties and their unemployment rates for 2019 and 2021.
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:
county names, County;
unemployment rates for 2019, y2019;
unemployment rates for 2021, y2021.
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 2019 and 2021).
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 2019 and 2021.
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. In this working example, the layer is saved as a shapefile format. A new column's values are set to 0 by default (shapefiles do not have a No Data data type).
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 2019 from that of 2021.
In the Fields box, double-click on y2021. This will add the field name to the expression box.
Note that you could have also manually typed the expression $feature.y2021 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 !y2021! (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.y2021 - $feature.y2019
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 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 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, explore the Tissot indicatrix tutorial.
This completes this tutorial.