9

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?

3
  • 1
    You cannot perform table to table if the Data Types doesn't match. I know I tried. Commented Jun 4, 2014 at 18:47
  • please elude to the data source format and version. (ent database, shapefile, filegdb, personal gdb?) Commented Sep 16, 2015 at 18:51
  • @Brad working with shapefiles in arcgis 10.2, the data source is locally on my computer Commented Sep 16, 2015 at 19:01

10 Answers 10

5

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?

3

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.

3
  • need precision. since 10.2.1 Commented Dec 3, 2015 at 22:19
  • @GeoStoneMarten Alter fields at 10.2.1 seems to only be for renaming fields whereas my answer relates to modifying data types and I think remains valid. However, the answer by @Paul suggests Alter Fields expanded its functionality to include modifying data types at 10.3. Commented Dec 3, 2015 at 23:13
  • Not only but yes if there is existing data... Ok for else Commented Dec 3, 2015 at 23:21
2

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).

2

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:

  1. Add a new field with a temporary name and the correct data type
  2. Use Calculate Field or cursors (with casting, if needed)
  3. Delete old field
  4. Alter Field to rename the temporary field
  5. (Optional) Copy the table with some field mappings to restore original order

I'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....

4
  • 1
    I usually rename the old field first. that way I can -recreate the new field, calculate the values, and then delete the old field.when you start to calculate the values you may need to select all non-null values. and or convert/split any string values Commented Sep 16, 2015 at 19:07
  • 1
    also et tools has some free functions that would be helpful. ian-ko.com Look at geo-wizards free functions. Commented Sep 16, 2015 at 19:09
  • @Brad I have been looking into free functions, xtools has been helpful but im always open to more/better options. thank you for the input Commented Sep 16, 2015 at 19:28
  • @BradNesom, good point! That would make a lot more sense. Commented Sep 16, 2015 at 21:07
1

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.

1

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.

1

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.

0

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"

0

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:

  1. Export both tables (.dbf)

  2. Open table Y in excel.

  3. Open table X in excel.

  4. 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.

  5. You now have a new table containing the data from both tables, with the corresponding data types.

6.Import this table in ArcMap

0
0

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.