0

My task is to convert .tab files from a directory (C:\Users\Vadim\Downloads\vec\MapInfo\snp) to a single GML file (snp.gml). I use OSGeo4w Shell. So I wrote a following command:

ogr2ogr -f "GML" C:\Users\Vadim\Downloads\vec\snp.gml -dsco FORMAT=TAB C:\Users\Vadim\Downloads\vec\MapInfo\snp

But it printed an error:

FAILURE: Unable to open datasource 'C:\Users\Vadim\Downloads\vec\MapInfo\snp' with the following drivers...

Could you please help me to get this command work.

  • At least -dsco FORMAT=TAB will do nothing because you want to write out GML and that format does not have such dataset creation option. Does ogrinfo C:\Users\Vadim\Downloads\vec\MapInfo\snp list your tab files as layers? – user30184 Oct 17 '18 at 11:20
  • no, the same error appears – Vadim Oct 17 '18 at 11:23
  • And you certainly have tab files there dir C:\Users\Vadim\Downloads\vec\MapInfo\snp\*.tab ? – user30184 Oct 17 '18 at 11:54
  • exactly, it listed all the tabs – Vadim Oct 17 '18 at 11:57
  • 1
    And is ogrinfo OK if you run it for one of the tab files ogrinfo C:\Users\Vadim\Downloads\vec\MapInfo\snp\my_file.tab? Do you have any other files than .tab and accompanied files (dat, id, map) in that directory? – user30184 Oct 17 '18 at 12:09
2

GDAL tries to detect MapInfo vector files from a directory https://www.gdal.org/drv_mitab.html. However, the autodetection may fail if there are other files in the same directory. For example, if directory contains shapefiles only those are reported as layers because the shapefile driver makes the test first.

In your case you found yourself that you had one raster tab file in your data directory. Obviously that fooled ogrinfo and ogr2ogr to believe that there are no vectors at all in the directory.

The solution was to delete the extra tab file from the directory. Best practice is probably to keep only the MapInfo vector files (.TAB, .MAP, .DAT, .ID) in a directory that will be used as a GDAL dataset with multiple layers.

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.