Convert Field Units
Summary
Converts every value of a numeric field from one measurement unit to another, into a new field or in place: inches to millimeters, acres to hectares, degrees Fahrenheit to degrees Celsius, percent slope to degrees, tree diameters to basal area. The units are the catalog of the Unit Converter: more than 1,200 units in 23 measurement classes, plus any units and classes you have added in its My Units tab.
The Convert a Field tab of the Unit Converter window runs this tool. Run it from the Geoprocessing pane, in ModelBuilder or in Python when that suits better: it is in the Data Tools toolset of the Jenness Enterprises Tools toolbox.
Usage
- Which records. A layer or table view converts only the records it shows: when it has a selection, only the selected records are converted, and its definition query is honored. A table or feature class given by its path converts every record.
- Where the values go. A name that is not a field yet becomes a new Double field; in a geodatabase its alias says what it holds, such as Length in millimeters (from inches). The name of an existing numeric field replaces that field's values, and the name of the input field itself converts the values in place. Left empty, the name is made from the input field's name and the To unit, no longer than 10 characters for a shapefile or dBASE table.
- The field is documented. The tool writes the field's description into the Fields section of the dataset's metadata: what the field holds, the field it was converted from, the two units, this tool and the date, the definition of the To unit with its value in its class's base unit (1 millimeter = 0.001 meter), the unit as the field's units of measure, and the smallest and largest converted values. Converting in place records that the field held the From unit and now holds the To unit. The description can be read on the dataset's Metadata tab in the Catalog pane.
- Converting in place is permanent. ArcGIS Pro's Undo does not bring back a geoprocessing edit, so keep a copy of the data, or write to a new field, when in doubt.
- Integer fields. Values written into an integer field are rounded to whole numbers, and the tool warns that it did so.
- Empty values. A record with no value, or whose value has no converted value (a negative circle area has no diameter), is left empty. Shapefiles and dBASE tables cannot hold an empty value, so those records get -999 there instead, and the run messages say how many.
- Measurement class. The From and To units must be in the same class. Choosing a class shortens both unit lists, and choosing a From unit with no class chosen fills the class in.
- Unit names. Units are named as in the Unit Converter window, whose Find box also finds them by the names ArcGIS Pro uses, such as FeetUS or AcresUS.
- Precision. Units go through their exact definitions wherever one exists; see Units and their definitions on the Unit Converter page.
An example: route lengths in miles
In the
Corridor Evaluation Tutorial,
Patch Analysis
draws the black bear's route through the patches of its corridor
as polyline segments, with each segment's length in meters in its
Length_m field. To have the lengths in miles as well,
the tool is set up as below. The Convert a Field tab of the
Unit Converter
window runs the same conversion, and its Open as Geoprocessing
Tool button opens the tool like this, filled in.
Length_m field, meters to miles, and the new
field Length_miles.
The tool can also be run in a model, where it passes the table on to the next step.
Parameters
| Label | Explanation | Data type |
|---|---|---|
| Input table or layerRequired · in_table | The table, feature class, layer or table view whose field is converted. A layer or table view converts only the records it shows. | Table View; Feature Layer; Table; Feature Class |
| Field to convertRequired · in_field | The numeric field holding the values to convert. | Field |
| Measurement classOptional · unit_class | The class of the two units: Length and Distance, Area, Volume and so on, including any class of your own. It shortens the unit lists. | String |
| From unit (the units the field holds now)Required · from_unit | The unit the values are in now, named as in the Unit Converter, such as inches, acres or degrees Fahrenheit. | String |
| To unitRequired · to_unit | The unit to convert to, in the same class. | String |
| Output field name (a new field, or the input field to convert in place)Optional · out_field | The field that receives the converted values: a new Double field, an existing numeric field whose values are replaced, or the input field itself. | String |
| Updated tableDerived · out_table | The input, with the converted values, for chaining the tool in ModelBuilder. | Table View |
Python
Stream lengths from feet to meters into a new field, then tree heights from inches to millimeters in place:
import arcpy
arcpy.ImportToolbox(r"C:\path\to\JennessEnterprisesTools.pyt") # your install path
arcpy.jenness.ConvertFieldUnits(
in_table=r"C:\data\streams.gdb\reaches",
in_field="Length_ft",
unit_class="Length and Distance",
from_unit="feet",
to_unit="meters",
out_field="Length_m")
arcpy.jenness.ConvertFieldUnits(
in_table=r"C:\data\plots.gdb\trees",
in_field="Height",
from_unit="inches",
to_unit="millimeters",
out_field="Height") # the input field itself: converted in place
Recommended citation
Credits
By Jeff Jenness, Jenness Enterprises (www.jennessent.com). The catalog of units and their definitions comes from his Unit Converter program of 2000 and 2001.
Licensing information
Works at every ArcGIS Pro license level (Basic, Standard, Advanced). No extension licenses are required.
Related tools and pages
- Unit Converter — the window: single numbers, the catalog's definitions, and your own units.
- Patch Analysis — the tool whose route segments the example converts.
- Corridor Evaluation Tutorial — where those segments come from.
- Finding the toolbox for Python — the path for the ImportToolbox line.