0

I have two shapefiles both containing the same attributes. However, when I merge them, instead of adding the fields vertically, it's adding the fields from one shapefile to another. Resulting in empty columns, is this happening because my field names are different as I'm joining them with CSVs?

enter image description here

Vince
  • 20,017
  • 15
  • 45
  • 64
Charan
  • 1
  • 1
  • 5
  • "Merge", not "Append"? As the Merge tool doc states, Use the Append tool to combine input datasets with an existing dataset. – Vince Aug 03 '22 at 01:57
  • @vince i tried doing that but i get schema does not match even though the variables have same datatype just different names – Charan Aug 03 '22 at 02:05
  • So you're getting what you asked for. If you want an Append, you need to make sure the feature classes have the same columns (name and type) or you need to get very good with field mapping. – Vince Aug 03 '22 at 02:23
  • @Vince what's the easiest and quickest way cuz rn im doing 2 shapefiles, but later i will be appending a lot of layers – Charan Aug 03 '22 at 02:27
  • The easiest way is to name the columns as you need them from the start. – Vince Aug 03 '22 at 02:48
  • Following on from Vince, the second easiest way would be create the fields and copy the data into them before the append, twice (for each layer), and then delete the original fields and continue to the append. – Keagan Allan Aug 03 '22 at 06:08
  • @vince is there to do this at once. I don't want to have 12 add/calculate field tools – Charan Aug 03 '22 at 17:51
  • If you can't rename the columns from the start (eg, because the data comes from another source regularly), then you can use the Append tool with the option to match fields using a field map, instead of requiring all the fields to have the same names. – Son of a Beach Aug 03 '22 at 23:19

1 Answers1

1

The problem your facing is the subject of datacleaning. If you have two datasets with the same attributes with different spellings/names/type(string or numeric ea), using tools as merge or append will regard the attributes as different/unique or throw an error (in case of non matching data types). So before merging or appending datasets/tables, you will always have to make sure the type and name of matching attributes are the same.

In ArcGIS Pro, you can use the Field Map option within the Merge tool. You can delete all output fields that you don't want to keep. Then you can select each output field. When selecting an output field, source will show you all datasets that have a matching attribute field name. You will then have to add all datasources for which you need to map the attribute with the wrong field name to the selected Output field name (this will hopefully make sense when you try it). You will have to do this for all the output fields you want to keep. If you perform a merge on all layers in one step, you will have the least amount of work when using the Field Map option (compared to doing the merges in multiple steps). Otherwise you will have to go through the output fields multiple times.

Alternatively you can easily rename columns/field names in QGIS before bringing the shapefiles into ArcGIS. Or if the problem is with the column names in the CSV files, just use any text editor to change the column names.

Regarding the use of merge or append in ArcGIS Pro: The Merge tool and Append tool in ArcGIS can combine data from different datasets in the same way, depending on how you setup the tools. The most important difference between them (to me at least) is that Merge will write the result to a new dataset, while Append will add the data to an existing or target dataset. For these types of operations I like the use of the Merge tool as it is often safer as with Merge you leave the original datasets intact. If you use Merge (in the ModelBuilder) in a series of operations, you can use Append following a merge without changing your input data.

Vince
  • 20,017
  • 15
  • 45
  • 64
JeeHaa
  • 61
  • 1
  • 5