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 | |||||||||||
Line features | |||||||||||
Annotation features | |||||||||||
Point features |
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:
- You right-clicked a field that is managed by ArcGIS and therefore cannot be edited manually. These include the ObjectID (OID or FID) field; the Shape_Length and Shape_Area fields for a geodatabase feature class; the Area, Perimeter, and <Coverage># fields for a point or polygon feature class in a coverage; and the FNODE#, TNODE#, LPOLY#, RPOLY#, Length, and <Coverage># fields for an arc feature class in a coverage.
- The table's data source is read-only, write access can't be established to the folder or geodatabase, or the data source is a format that can't normally be modified in ArcMap. You also may be working with EDG or SDC data or ArcIMS services, which usually allow you to open their attribute tables but not modify the data.
- You are not in an edit session and you need to be editing to calculate the data. For example, you must be in an edit session when working with versioned ArcSDE data or a feature class that participates in a geodatabase topology, a geometric network, or a relationship class.
- The field belongs to a table that has been joined to your table. You can only calculate values for fields in the origin table.
- The field may be a raster, BLOB, or Global ID type, which cannot be calculated. To review the type of a field, right-click it and click Properties.
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.