4

It is no problem in QGIS to open MapInfo .tab files with combined geometry type. If a single .tab file contains points, polylines and polygons then QGIS will load three separate layers for each geometry type.

But how can I export these layers to a single .tab file after editing? It is important because many organizations (business partners) still use MapInfo and they didn't want their geospatial data structure to be modied, changed (broken).
The problem is in the symbology retaining problem. QGIS saves simple polygon and polyline symbology settings when exporting layers (but not point layers) to MapInfo .tab format. (colour of polygons and the width and colour of outline; colour and width of polylines). The edited primary .tab file doesn't contain the symbology of added objects. That's why the primary .tab file must be exported and not simply edited.

2
  • Data models of QGIS and MapInfo are not totally interoperable. QGIS does not allow many geometry types on one layer while MapInfo does. If interoperability is important for your business partners they should consider to change their data structure and use separate layers for different geometry types as well. If that is not possible then you must find some usable workaround. I guess that's your situation now. Could you tell if using MID/MIF instead of TAB would be acceptable?
    – user30184
    Aug 10 '21 at 8:50
  • @user30184 yes, exporting multiple layers with different geometry types from QGIS to a single layer in mid/mif format is also acceptable.
    – KVO
    Aug 10 '21 at 12:38
1
+50

You can export point, line, and polygon layers into separate files and combine them with ogr2ogr.

Test data

points.mif

Version 300
Charset "Neutral"
Delimiter ","
Columns 2
  R_G_B Char(254)
  COLOR Char(254)
Data

Point -90.5566923029394 14.5906248310583
    Symbol (35,0,12)
Point -90.5515144114431 14.6013641615691
    Symbol (35,0,12)
Point -90.5407750809323 14.5938849849634
    Symbol (35,0,12)

lines.mif

Version 300
Charset "Neutral"
Delimiter ","
Columns 2
  R_G_B Char(254)
  COLOR Char(254)
Data

Line -90.5439393479578 14.6041448810763 -90.5314740536149 14.6133500215141
    Pen (1,2,9288960)
Line -90.5536239227934 14.6182402523717 -90.5630208369904 14.6045284285946
    Pen (1,2,9288960)
Line -90.557651171735 14.5991587633392 -90.5396244383776 14.5850633920438
    Pen (1,2,9288960)

polygons.mif

Version 300
Charset "Neutral"
Delimiter ","
Columns 2
  R_G_B Char(254)
  COLOR Char(254)
Data

Region 1
  4
-90.5361725107134 14.6028024647625
-90.5243784245275 14.6012682746895
-90.5358848500747 14.5908166048174
-90.5361725107134 14.6028024647625
    Pen (1,2,0)
    Brush (2,255)
Region 1
  4
-90.5701164660778 14.5969533651093
-90.5593771355671 14.5942685324816
-90.5737601675012 14.5838168626095
-90.5701164660778 14.5969533651093
    Pen (1,2,0)
    Brush (2,255)
Region 1
  4
-90.5453776511512 14.6222675013133
-90.533200017447 14.6205415374812
-90.5498843344906 14.6101857544886
-90.5453776511512 14.6222675013133
    Pen (1,2,0)
    Brush (2,255)

ogr2ogr commands for combining points, lines, and polygons into layer "collect"

ogr2ogr -f "MapInfo File" collect.tab points.mif -nln collect
ogr2ogr -f "MapInfo File" -update -append collect.tab lines.mif -nln collect
ogr2ogr -f "MapInfo File" -update -append collect.tab polygons.mif -nln collect

ogrinfo that confirms that all features with individual styles are now on the same layer

ogrinfo collect.tab -al
INFO: Open of `collect.tab'
      using driver `MapInfo File' successful.

Layer name: collect
Geometry: Unknown (any)
Feature Count: 9
Extent: (-90.570000, 14.580000) - (-90.510000, 14.620000)
Layer SRS WKT:
ENGCRS["Nonearth",
    EDATUM[""],
    CS[Cartesian,2],
        AXIS["(E)",east,
            ORDER[1],
            LENGTHUNIT["Meter",1]],
        AXIS["(N)",north,
            ORDER[2],
            LENGTHUNIT["Meter",1]]]
Data axis to CRS axis mapping: 1,2
R_G_B: String (254.0)
COLOR: String (254.0)
OGRFeature(collect):1
  R_G_B (String) = FF0000
  COLOR (String) = 1
  Style = SYMBOL(a:0,c:#000000,s:12pt,id:"mapinfo-sym-35,ogr-sym-9")
  POINT (-90.57 14.6)

OGRFeature(collect):2
  R_G_B (String) = FF0000
  COLOR (String) = 1
  Style = SYMBOL(a:0,c:#000000,s:12pt,id:"mapinfo-sym-35,ogr-sym-9")
  POINT (-90.54 14.6)

OGRFeature(collect):3
  R_G_B (String) = FF0000
  COLOR (String) = 1
  Style = SYMBOL(a:0,c:#000000,s:12pt,id:"mapinfo-sym-35,ogr-sym-9")
  POINT (-90.54 14.6)

OGRFeature(collect):4
  R_G_B (String) = 8DBD00
  COLOR (String) = 62
  Style = PEN(w:1px,c:#8dbd00,id:"mapinfo-pen-2,ogr-pen-0",cap:r,j:r)
  LINESTRING (-90.54 14.61,-90.54 14.61)

OGRFeature(collect):5
  R_G_B (String) = 8DBD00
  COLOR (String) = 62
  Style = PEN(w:1px,c:#8dbd00,id:"mapinfo-pen-2,ogr-pen-0",cap:r,j:r)
  LINESTRING (-90.54 14.62,-90.57 14.61)

OGRFeature(collect):6
  R_G_B (String) = 8DBD00
  COLOR (String) = 62
  Style = PEN(w:1px,c:#8dbd00,id:"mapinfo-pen-2,ogr-pen-0",cap:r,j:r)
  LINESTRING (-90.57 14.6,-90.54 14.58)

OGRFeature(collect):7
  R_G_B (String) = 0000FF
  COLOR (String) = 5
  Style = BRUSH(fc:#0000ff,id:"mapinfo-brush-2,ogr-brush-0");PEN(w:1px,c:#000000,id:"mapinfo-pen-2,ogr-pen-0",cap:r,j:r)
  POLYGON ((-90.54 14.61,-90.51 14.6,-90.54 14.6,-90.54 14.61))

OGRFeature(collect):8
  R_G_B (String) = 0000FF
  COLOR (String) = 5
  Style = BRUSH(fc:#0000ff,id:"mapinfo-brush-2,ogr-brush-0");PEN(w:1px,c:#000000,id:"mapinfo-pen-2,ogr-pen-0",cap:r,j:r)
  POLYGON ((-90.57 14.6,-90.57 14.6,-90.57 14.58,-90.57 14.6))

OGRFeature(collect):9
  R_G_B (String) = 0000FF
  COLOR (String) = 5
  Style = BRUSH(fc:#0000ff,id:"mapinfo-brush-2,ogr-brush-0");PEN(w:1px,c:#000000,id:"mapinfo-pen-2,ogr-pen-0",cap:r,j:r)
  POLYGON ((-90.54 14.62,-90.54 14.62,-90.54 14.61,-90.54 14.62))
8
  • is it possible to combine .tab files with ogr2ogr ? (I have not checked your answer with .mif files yet)
    – KVO
    Aug 10 '21 at 12:53
  • I tried combining .tab files with success. I noticed that the ogr2ogr option -nln works in a special way with MapInfo files. You cannot rename the layer but it will have the same as the name of the mif/tab file. However, for appending data you must still use the -nln option.
    – user30184
    Aug 10 '21 at 13:38
  • Hi. I have a new question. How to convert (using QGIS GUI or ogr2ogr) a .mif file into .tab format without loosing symbology of point features? gis.stackexchange.com/questions/412373/…
    – KVO
    Sep 23 '21 at 15:10
  • Do you mean that ogrinfo shows some style for mif, but not when QGIS converts it into tab? Nothing like "mapinfo-sym-35,ogr-sym-9" in the info about tab?
    – user30184
    Sep 23 '21 at 18:19
  • I mean QGIS 3.20 shows embedded symbology of .mif and .tab files when I add them to the QGIS project. (it is a new feature in 3.20 version). But it can't export a point layer with retaining symbology by the "Save as" dialog menu (I have checked an output .tab layer in MapInfo 17). QGIS can save only symbology of polygon and polyline features, but not point. So I need to convert a .mif file into .tab format without using MapInfo software. But I'm not familiar with ogr2ogr console.
    – KVO
    Sep 24 '21 at 1:53

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.