In many scenarios it is necessary to convert a field of string values in an attribute table to numeric values, typically because the original data type was not set or recognized, so that proper data analysis can be performed. To preserve data integrity (especially if sharing or importing data from outside sources) the method for converting fields to different types is to copy the data to a new field of the desired type.
Three solutions are described below; one pertaining to ArcGIS for Desktop 10.1 through 10.4.1; the second solution is for ArcGIS Pro 1.x; the third is for older software (such as ArcView GIS 3.x.)
ArcGIS Desktop 10.1 thru 10.4.1
Open ArcMap, and open the layer or file geodatabase attribute table.
In ArcMap, the data type of the field can be checked by right-clicking the Field header and selecting Properties. In this example, a String type field is converted to Double.
On the top-left of the Table window, click the Table Options drop-down button and select Add Field.
Create a field of type Double.
Provide a Name.
Set the Precision and Scale if desired..
Right-click the newly created field's header and select Field Calculator.
If the string field contains only numeric values, the following provides the desired result:
Enter [String field name]into the expression window.
However, if the string field contains mixed alphanumeric and numeric values, a more detailed approach is required:
With the Parser set to VB Script, and with Show Codeblock checked, copy-paste the code below into the Pre-Logic Script Code text window, and replace "String field name" below with the name of the field to be converted. Leave in the left and right brackets:
Dim String, Check
String = [String field name]
Check = IsNumeric(String)
If Check = True then
Output = CDbl(String)
Output = null
In the <Double field name> (in this example, "DoubleV =") expression window, type:
The Field Calculator window looks like this:
Once the script completes, the Double field is populated with the values from the String field.
If a String field contains values with non-numeric characters or symbols, the value of that cell remains at the default of zero when converting to the Double field.
ArcGIS Pro 1.x
Open an ArcGIS Pro project. Add the applicable data / table to the Project.
Right-click the data / table, and select Attribute Table.
Click the New button to create a new field. In the Fields list view, give the field a name, set the Data Type to Double, and ensure the Number Format is set to Numeric (and adjust the settings as desired). If necessary, set domain, default, and length values.
Using the top ribbon, Save the edits to the table, and close the Fields tab.
Right-click the header of the newly-created Double field, and select Calculate Field. The Calculate Field Geoprocessing dialog opens.
If <Null> (empty) values are in the String field, select a subset without them prior to performing the calculation, and type the following into the Expression text box: