1

I have a MapInfo TAB consisting of 5 files: .tab, .map, .id, .aid, .accdb

The attributes seem to be stored in the .accdb Microsoft Access database file.

Using GDAL 3.5.0 on Windows 10 installed via the QGIS Standalone Installer Version 3.26.

If I point ogrinfo to the .tab file or the containing directory, all I get is "Unable to read datasource ...".

The list of drivers includes "MapInfo File".

The .tab (File With Ümlauts.tab) file reads (censored/changed, UUIDs replaced):

!table
!version 1000
!charset WindowsLatin1

Definition Table
  File "File With Ümlauts.accdb"
  Type ACCESS TABLE "File_With_Ümlauts" Charset "WindowsLatin1"
  Fields 9
    Some_Field Char (3) ;
    some_area Integer ;
    some_Text Char (50) ;
    A_Number Float ;
    Another_Something Char (12) ;
    And Float ;
    More Char (4) ;
    fields Float ;
    in_Various_cases Char (8) ;
begin_metadata
"\DefaultStyles" = [stripped for publication on GIS.SA]
"\MapInfo" = ""
"\MapInfo\TableID" = "5303f130-f5fd-11ec-b939-0242ac120002"
"\MapInfo\ParentTableID" = "181772f4-c235-4b27-810b-eb91f71a1611"
"\IsReadOnly" = "FALSE"
end_metadata

I installed the Microsoft Access Database Engine 2016 Redistributable but that did not magically fix it.

It allowed me to add the .accdb file as ODBC data source in Windows and read it as non-spatial data source with OGR though:

C:\Temp\>ogrinfo odbc:gdaltest -so -al
INFO: Open of `odbc:gdaltest'
      using driver `ODBC' successful.

Layer name: File_With_Ümlauts
Geometry: Unknown (any)
Feature Count: 1
Layer SRS WKT:
(unknown)
MAPINFO_ID: Integer (10.0)
Some_Field: String (3.0)
some_area: Integer (10.0)
some_Text: String (50.0)
A_Number: Real (0.0)
Another_Something: String (12.0)
And: Real (0.0)
More: String (4.0)
fields: Real (0.0)
in_Various_cases: String (8.0)

I searched the list of installed OSGeo4W packages with osgeo4w-setup and spotted nothing relevant missing with the terms "access", "odbc", "mapinfo", "tab" or even "mdb".

(How) Can one read a MapInfo File in GDAL or QGIS that has its attributes in an Microsoft Access .accdb?

4
  • 1
    Any chance of a link to a sample of this sort of data?
    – Spacedman
    Jun 27 at 9:30
  • Sadly it's proprietary customer data but I added the censored .tab file contents. Jun 27 at 9:44
  • Can you open the .accdb file in Access and see the data? Or does it come from a database connection defined within the Access project?
    – Spacedman
    Jun 27 at 10:17
  • I don't have Access but managed to read the file as non-spatial data file with GDAL after I added it as a ODBC source in Windows. Added to the post. I assume GDAL just does not recognise the file as a source or it would require serious manual shenanigans. Jun 27 at 12:15

1 Answer 1

2

Looks like the GDAL driver doesn't support Access as a table type. Code here:

https://github.com/OSGeo/gdal/blob/35c07b18316b4b6d238f6d60b82c31e25662ad27/ogr/ogrsf_frmts/mitab/mitab_tabfile.cpp#L691

seems to accept NATIVE, LINKED, or DBF. I think with "NATIVE" the attributes are in the .DAT file. What you might have to do is:

  1. Convert the relevant Access database to DBF.

  2. Change the .tab file to get its attributes from the DBF. I think this means removing the "File" line and changing the "Type" to Type DBF. If your DBF has the same name as the TAB file it should then find it.

I just tried doing this sort of surgery and managed to splice a shapefile .DBF into a .TAB file and it seemed to come out of anaesthetic okay...

4
  • Whoa, great investigation there, thank you! That sounds like a horribly wonderful workaround and I will try it :D Jun 27 at 13:08
  • I tried the same (using a trial of WithData AccessToDbf) but the resulting MapInfo File shows as Geometry: Unknown (any) and Feature Count: 0 to GDAL. Jun 27 at 14:46
  • Really hard to debug without an example :( I might play some more and see how specific things need to be...
    – Spacedman
    Jun 27 at 18:07
  • Probably not worth it to be honest, but it might help others in the future. Jun 27 at 19:54

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.