5

I have a situation where I need to merge a large number of spatial files into a single output with a free tool like QGIS, rather than FME or Alteryx.

Along the lines of this post: Merging multiple vector layers to one layer using QGIS?

However, I have some point features, some line features, and some polygon features. This rules out outputs like shapefiles, but anything else is fine like GML, TAB, or a database.

Is there anyway to do this in QGIS?

Every process or model I try makes a shapefile at some point which means this can't work.

  • You want to place them in the same database but as separate layers or actually merge together lines, points and polygons? – BERA Mar 31 '17 at 10:51
  • 1
    I need a single table with a single geometry column (Or a single TAB file would be easier). No features are to be changed in any way. – AK9 Mar 31 '17 at 12:00
  • A good point to start is to take a look at this post. I think you should consider using PostGIS to manage your datasets. – MickyInTheSky Mar 31 '17 at 13:57
  • Do all layers share the same attributes? – user30184 Mar 31 '17 at 14:16
  • I believe Sqlite or Spatialite will allow multiple feature types (lines, points, polygons) in a single geo enabled table. – klewis Mar 31 '17 at 16:40
7

You can merge layers with different geometry types together with ogr2ogr.

Here is an example about merging an point shapefile and polygon shapefile into GeoPackage as a new layer "merged" that has a generic geometry type.

ogr2ogr -f gpkg merged.gpkg point.shp -nln merged -nlt geometry
ogr2ogr -f gpkg -update -append merged.gpkg polygon.shp -nln merged -nlt geometry

ogrinfo merged.gpkg merged
INFO: Open of `merged.gpkg'
      using driver `GPKG' successful.

Layer name: merged
Metadata:
  DBF_DATE_LAST_UPDATE=2017-03-31
Geometry: Unknown (any)
Feature Count: 2
Extent: (309.000000, 478.000000) - (599.000000, 604.000000)
Layer SRS WKT:
(unknown)
FID Column = fid
Geometry Column = geom
attr: String (1.0)
OGRFeature(merged):1
  attr (String) = B
  POINT (382 478)

OGRFeature(merged):2
  attr (String) = A
  POLYGON ((309 584,599 604,466 493,309 584))

However, you will have some problems with QGIS with using that layer because QGIS can't handle points, lines, and polygons on a same layer. QGIS requires that layer is split by the geometry type

enter image description here

You can open the merged layer as a single layer with OpenJUMP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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