How can I change the data type in an attribute table in ArcGIS for multiple fields?
For example, if the fields have been exported as a string from Excel, and I would like to use them as numerical values?
How can I change the data type in an attribute table in ArcGIS for multiple fields?
For example, if the fields have been exported as a string from Excel, and I would like to use them as numerical values?
You can't change the data type of a field in ArcGIS, you'll have to create new fields with the data types you want and populate them with the values from your current fields. See: How to change field formats in ArcGIS 10.1 geodatabase?
You do not mention what version of ArcGIS for Desktop you are using or where your data is stored but there is a Modifying field properties page that describes how, using ArcGIS 10.2 (or later):
Some field properties can be changed after the table or feature class is created
... but this applies only to empty fields.
From 10.3 the above functionality is also available via the Alter Fields tool:
Rename fields and field aliases, or alter field properties.
You are able to change the field data type for the fields you have in your feature class. However, you will not be able to convert text fields to numeric. However, you can convert your numeric fields to strings. Take a look at the Esri help page. This is not only for Enterprise geodatabase, it works fine even for desktop geodatabases such as file geodatabase.
If the table or feature class is in an enterprise, workgroup, or desktop geodatabase, you must connect as the table owner to modify field properties.
Since you deal with Excel, the best way to make sure your data types are correct is to define cells data types directly in Excel before importing any data. If you have however got a text field with numbers, you can of course create a new field of the numeric type (integer or double, for instance) and calculate the values based on this text field. This will work fine if your numbers are really numbers ("12" will work, but "12-1" won't).
To my knowledge, this is not possible. In 10.3, Alter Field was expanded to allow altering field type; however, it still only works when the table doesn't have any records.
Here is one approach to doing this though:
Calculate Field or cursors (with casting, if needed)Alter Field to rename the temporary fieldI've never investigated it, but field mapping might work to cast fields to new data types, which would simplify this process considerably. Something to look into for sure....
An alternative way consists into opening your .dbf file in OpenOffice Calc (or equivalent) and modifing carefully the headers of its columns. E.g. change the type from C (Character) to N (Numeric). A simple advice: backup your file before trying.
Although you can't change te field name and data type in the dataset itself, it is possible to create a copy with the desired changes using the ArcGIS tool "Feature class to feature class". In the settings you can change, names, data types and other characteristics of the fields.
Before anything else, one must try to understand why ArcGIS imports a field as a string type instead of a numerical / double data type. I found that even if your cell (in Excel) is blank, if it has "spaces" inside (like when you press the spacebar), ArcGIS will interpret these as characters. If you remove them, you will see that they will now register as numeric fields.
Take a look at this document. You typically have to make sure data is in the correct format before and after importing.
"ArcGIS typically converts spreadsheet numeric fields to double precision (Double), which may not meet your needs. If necessary, create new fields of the desired type and calculate values into them"
If your goal is to add the data from a table X to another table Y, but you can't because the data types aren't corresponding, you can also follow these steps:
Export both tables (.dbf)
Open table Y in excel.
Open table X in excel.
Copy and paste the data from the table X to the table Y by making sure that you only copy the values, not the form.
You now have a new table containing the data from both tables, with the corresponding data types.
6.Import this table in ArcMap
No one has mentioned the X-Ray tools suite for ArcGIS. Just do a Google search for "X-Ray ArcGIS". There are several variants for each ArcGIS version and platform (ArcCatalog, ArcMap). Here is one version. Here is another. It supports many Field and Domain-related functions, including changing the field type, name, alias, domains, etc. in MS Excel and uploading changes back into the GDB.