[GIS] Merge multiple geometry type TAB files in QGIS/OGR

mergeogr2ogrqgistab

I have a number of vector layers with all types of geometry (point, line/multiline, poly) and I want to combine them into a single layer in QGIS. I know MapInfo can do it but with the other 99% of my workflow in QGIS it's the last step to having a complete pipeline.

It seems there are a number of tools to merge shapefiles together (assuming equivalent geometry types) in QGIS but this doesn't help me. There's ogr2ogr but running the following statement gives me a failure:

ogr2ogr -f "MapInfo File" merge.tab points.tab
ogr2ogr -update -append merge.tab lines.tab -f "MapInfo File"
FAILURE:
Unable to open existing output datasource 'merge.tab'

It'd be fine if I wanted to merge a bunch of layers with the same geometry (use SHP, merge, save result as TAB), but multiple geometry types are eluding me.

I could write a little program using Tatuk Developer Kernel but I'm not that happy with its handling of projections (using EPSG:28355 it seems to create a projection that is 'custom' when viewed in QGIS or MapInfo).

Best Answer

OGR cannot update an existing TAB (or MIF/MID) file. It can read and can create, but not update. From http://www.gdal.org/ogr/drv_mitab.html:

MapInfo TAB and MIF/MID

MapInfo datasets in native (TAB) format and in interchange (MIF/MID) format are supported for reading and writing. Update of existing files is not currently supported.

As a workaround, consider converting to some intermediate format, doing the merge / update there, and then exporting to TAB at the end if you have to use that format.

Related Question