113

I've imported several shapefiles which where exported from a Mapinfo .tab. Several .tab-files are imported resulting in 20+ layers.

Afterwards I want to export it to GeoJSON; but I'm reluctant to select each layer and export it manually.

Is there a way to merge all the layers into one using QGIS?

2
  • All these functions can be accessed via the Sextante plugin, also in Lisboa
    – user20470
    Commented Jul 26, 2013 at 8:59
  • yes, the tools works perfectly. Just if the input shapefiles are in UTF8, the output shapefile lose atributes.... is there any way to say QGIS to create SHP in UTF8 ? something like in ArcGIS, where you can in registry set the value defaul codepage to UTF8?
    – user22228
    Commented Sep 23, 2013 at 10:11

5 Answers 5

95

You can use the 'merge shapefiles to one' function under the menu vector|Data management tool. You can merge all files in the input directory or select specific files in the input directory.

enter image description here

The same applies as for MMqgis tool: merged layers must all be of the same geometry type. Also, if the source layers have different attributes fields, the merged file will contain all fields, but with NULL values inserted when a source layer does not have a specific field.

91

You can use MMQGIS tools for merging...

mmqgis

The merge layers tool merges features from multiple layers into a single shapefile and adds the merged shapefile to the project. One or more layers are selected from the "Select Source Layers" dialog list box and an output shapefile name is specified in the "Output Shapefile" dialog field.

Merged layers must all be the same geometry type (point, polygon, etc.). If the source layers have different attribute fields (distinguished by name and type), the merged file will contain a set of all different fields from the source layers with NULL values inserted when a source layer does not have a specific output field.

4
  • 21
    There is such an option, under the vector menu, data management tool
    – Ecodiv
    Commented Aug 1, 2012 at 7:56
  • what about if the two or more layers have different coordinate systems?? gis.stackexchange.com/questions/279571/…
    – aaaaa
    Commented Apr 16, 2018 at 9:23
  • 1
    One benefit of the MMQGIS merge tool is that it can handle attribute fields with the same name but different types - the builtin merge layer tool throws an error when this happens. Commented Jun 30, 2020 at 5:11
  • 1
    MMQGIS cuts the column characters in the data attribute table to just 10. See my answer below.
    – Geographos
    Commented Dec 9, 2021 at 11:58
15

In the meantime, a tool called "Merge vector layers" has been added to QGIS under Vector > Data Management Tools > Merge Vector Layers or under Vector general in the Processing Toolbox (Ctrl+Shift+T).

merge vector layers screenshot

12

You can also use the v.patch module under GRASS GIS commands. It's available in the processing toolbox.

You can search for it when the dropdown at the bottom of the Processing Toolbox window is switched from "Simplified interface" to "Advanced interface".

enter image description here

0

I would suggest using the Vector - Data Management Tools -> Merge Vector Layers instead of MMQGIS -> Combine -> Merge Layers.

The reason behind is is your data attribute table. MMQGIS reduces the characters limit to 10, unlike the Merge Vector Layers tool. You can still use it, although be aware that your naming will be cut, as you can see below:

enter image description here

4
  • Thank you for your answer, but can you please tell us how your answer differs from @stopopol's answer?
    – Taras
    Commented Feb 23, 2022 at 8:00
  • It shows clearly which option we should use. I've marked in red the streaking difference between the MMQGIS merge layers and Merge Vector Layers. MMQGIS cuts column names at the same basis as shapefile does.
    – Geographos
    Commented Feb 23, 2022 at 9:25
  • I would suggest extending the answer from @stopopol's instead of putting it as a separate answer. why? because your answer wraps in end effect the "Merge Vector Layers" which was already mentioned.
    – Taras
    Commented Feb 23, 2022 at 9:41
  • I don't think it's a good idea. My answer basically combines both @stopopol and Aragon answer. Just noticed the difference between the two and decided to forewarn everyone, who has the data attribute columns longer than 10 characters.
    – Geographos
    Commented Feb 23, 2022 at 10:42

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