2

I am working in QGIS 3.4, and trying to merge 10 polygon shapefiles into a single shapefile. However, the result is not preserving the values for most of the shapefiles, it's NULL-ing them out for all but one of the shapefiles.

  1. Must the exact number of fields exist for all 10 shapefiles?
  2. If so, must the fields be ordered exactly the same for all 10 shapefiles?
  3. Must the fields be named the same for all 10 shapefiles?

2 Answers 2

5

1) No, not the exact number.
2) No, order does not matter.
3) Yes, common field names & types are necessary for values to transfer from the source shapefiles into the resultant merged shapefile.

For instance:
Shape1 has a name field of NAME (text)
Shape2 has a name field of TextID (text)
Both:
Have an attribution field of EditorID (text)

When merged, the attributes/columns that are common will transfer feature/row attributes, but the attributes/columns that are unique will only transfer feature/row attributes that were originally present, marking NULL in all other attributes/columns.

The image below demonstrates this using the above example:
enter image description here

You can either transfer attributes to common columns ahread of the merge, or do it after the merge using the field calculator.

3
  • 2
    In this example, the field calculator expression to copy the "NAME" values into "TextID" would be if(TextID = 0 OR TextID is NULL, NAME, TextID)
    – csk
    Oct 14, 2019 at 15:29
  • 1
    Thank you, Saijin_Naib. I was hoping for a quicker fix, but I just revised to match all field names, & field types/lengths exactly between shps & it worked.
    – Ashley
    Oct 15, 2019 at 13:26
  • Ashley, if you use Geopackage or another (not shapefile) datasource to store your data, you don't need to match lengths but merely field types & names. Can be a little bit less frustration when managing the data to be merged. Aside from that, it is almost unquestionably a superior format in every regard: switchfromshapefile.org Oct 15, 2019 at 15:20
2

With the QGIS > Vector general > Merge vector layers tool I recently ran into a similar issue (missing or ´NULL´ed attributes in the resulting merged layer). As a solution I recommend using the SAGA > Vector general > Merge vector layers tool:

enter image description here

It has additional options for adding source information and matching fields by name:

enter image description here

1
  • That's great! I never looked into that tool as I simply use the bundled QGIS Processing Algorithm, but this one is clearly better. Oct 15, 2019 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.