I am using the OGR MapInfo File driver to read a MapInfo TAB file. However, the function GetGeomType() returns 0 which means 'wkbUnknown` even if the features in the TAB are only multi-polygons.
Is it because MapInfo TAB can store many different GeomTypes in the same file?
If I take for granted that only one geometry type would always be in the TAB, how could I retrieve it?
driver = ogr.GetDriverByName("MapInfo File")
datasource = driver.Open(os.path.join(dirname,shapefileName))
layer = datasource.GetLayer(0)
geometryType = layer.GetGeomType()
>>>geometryType
>>>0
Best Answer
With the OGR MapInfo File driver, GetGeomType() will return wkbPoint, wkbLineString or wkbUnknown for MapInfo TAB file. The later being for polygons/multipolygons, or mix or geometry types.
Source is ogr/ogrsf_frmts/mitab/mitab_tabfile.cpp :
I imagine (I haven't coded that driver) that the reason is that regions can be either a mix of Polygon and MultiPolygon, hence it is not possible to expose a single geometry type. Well, in the shapefile driver, the same situation occurs and we expose wkbPolygon, but can indeed cause some issues when converting to other formats. A potential solution would be to declare MultiPolygon as geometry type and indeed return single Polygon in a MultiPolygon.