Fundamentals of field calculations

Entering values with the keyboard is not the only way you can edit values in a table. In some cases, you might want to perform a mathematical calculation to set a field value for a single record or even all records. Field Calculator in ArcMap lets you perform simple as well as advanced calculations on all or selected records.

In addition, you can calculate area, length, perimeter, and other geometric properties on fields in attribute tables.

Performing calculations on feature geometry

If you're working with an attribute table of a feature layer, you can easily calculate the area; perimeter; 3D perimeter; length; 3D length; coordinates of the centroid; coordinates of a point; minimum and maximum z-values; or coordinates of a start, end, or midpoint using the Calculate Geometry dialog box.

You can use the coordinate system of the data source or of the data frame when performing calculations. In addition, if one or more records are currently selected, only the selected records are calculated.

The following table shows the geometric properties you can calculate for different types of features:

Area

Perimeter

3D perimeter

Length

3D length

X-, y-, or z-coordinate of centroid

X-, y-, or z-coordinate of point

X-, y-, or z-coordinate of start point

X-, y-, or z-coordinate of endpoint

X-, y-, or z-coordinate of midpoint

Min, max of z-coordinate

Polygon features

Available

Available

Available

Available

Available

Line features

Available

Available

Available

Available

Available

Available

Annotation features

Available

Point features

Available

Geometric properties that can be calculated for specific types of features
NoteNote:

You can only calculate z-coordinates and 3D measurements of a feature if the feature is z-aware.

Geometry calculations in ArcGIS are planimetric—in other words, they take place in projected space, not spherical or geodesic space. You can only calculate the area, length, or perimeter of features if the coordinate system being used is a projected coordinate system. If the data source uses a geographic coordinate system, such as WGS 1984, and is therefore unprojected, you can use the projected coordinate system of the data frame to perform the calculations. Alternatively, you can project the data source.

Calculate Geometry works with any numeric or text field. For the most precise results, use a field of type double, with the desired number of decimal places. If you use an integer field, the result will be rounded up to a whole number. If you use a text field, you can include the unit abbreviation, choose the format, and so on, to easily create a ready-to-use field for labeling.

Reasons the Field Calculator might be disabled

If you find that the Field Calculator or Calculate Geometry commands are unavailable when you right-click a field, here are some things to check:

Advanced calculations with the Field Calculator

The Field Calculator lets you perform advanced calculations using VBScript or Python code blocks that process the data before calculations are made on the selected field. For example, using demographic data, you might want to find the largest age group by percentage of the population for each county in the United States. You can create a script that preprocesses your data using logical constructs such as IF...THEN statements and Select Case blocks. This lets you perform sophisticated calculations quickly and easily.

Simple field calculator expressions are entered into the Expression text box directly. More complex expressions, such as multiline scripts, looping, and branching, are entered in the Code Block box on the Calculate Field tool dialog box.

Related Topics


9/17/2012