OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.93k stars 2.57k forks source link

Conversion mapinfo file issue #11173

Open q1165600785 opened 4 weeks ago

q1165600785 commented 4 weeks ago

What is the bug?

I have two types of mapinfo files, one is. tab. map. id. dat, and the other is. tab. map. id. dbf. The first type can be opened, and when I convert to shp using ogr2ogr, the first type can be successfully converted, but the second type produces an empty property table

Steps to reproduce the issue

ogr2ogr

Versions and provenance

python gdal 4.7.1

Additional context

No response

jratike80 commented 3 weeks ago

There is no GDAL version 4.7.1. The MapInfo TAB format there are a bunch of files, usually .TAB, .DAT, .MAP, .ID, .IND. The format does not specify .dbf file, so it is something extra and skipped by the GDAL driver. However, the .DAT file is actully a dBase III file https://en.wikipedia.org/wiki/MapInfo_TAB_format. Could if be that somebody has renamad .DAT into .dbf for opening for investigating it with for example Excel? In that case it might work if you rename .dbf into .DAT. But if the .dbf file has been edited in any way your data is likely corrupted.

Anyway, using faulty MapInfo data as input is not a GDAL bug, Properties should not be in the .dbf file.

rouault commented 3 weeks ago

The format does not specify .dbf file, so it is something extra and skipped by the GDAL driver.

actually, I see there's code in the MapInfo GDAL driver to handle .dbf file

@q1165600785 Please attach to this ticket a .zip file containing all needed files

q1165600785 commented 3 weeks ago

IMG20241031082343 Sorry, I am unable to provide you with the test file at the moment as it is on the internal network. I uploaded an image and when I opened two tabs, I found that the tables they defined were one for native and the other for dbf. I think it may be related to this

rouault commented 3 weeks ago

We'll need access to the actual files to be able to diagnose

jratike80 commented 3 weeks ago

Notice that "actual files" do not need to contain your perhaps confidential data. Fake data files will do as well if they a) are known to be usable with MapInfo and b) produce the reported issue with GDAL.

q1165600785 commented 2 weeks ago

Sorry for uploading the file just now, I uploaded two types of mapinfo TAB files, I uploaded the file to my repository,They are test1 and test2 respectively. This is my test file

https://github.com/q1165600785/gdal_test

jratike80 commented 2 weeks ago

Is the "test2" set with the .dbf part written with MapInfo, and can MapInfo open it successfully?

jratike80 commented 2 weeks ago

ogrinfo test2.tab shows:

Lxh: String (20.0)
Dm: String (40.0)
Ydm: String (20.0)
Jdh: Real (9.0)
H85: String (20.0)
B: Real (15.10)
L: Real (15.10)
Ly: String (8.0)
M: String (10.0)
Hgd: Real (13.7)
ERROR 7: Unsupported field type!
ERROR 7: Unsupported field type!
ERROR 7: Unsupported field type!
ERROR 7: Unsupported field type!
ERROR 7: Unsupported field type!
ERROR 7: Unsupported field type!
ERROR 7: Unsupported field type!
ERROR 7: Unsupported field type!

Excel does not open the .dbf file, it claims that the contents of the file do not match with the extention of the file name. DBF file importer in the SpatiaLite gui application says that the dbf file is corrupted. However, the shp/dbf driver of GDAL can read data from the file with ogrinfo test2.dbf.

There is something odd in the dbf. I managed to make the test2.tab to work by writing the .dbf part again with ogr2ogr, and remaming the files

ogr2ogr  test2_2.dbf test2.dbf
ren test2.dbf test2.bak
ren test2_2.dbf test2.dbf
ogrinfo test2.tab -al
INFO: Open of `test2.tab'
      using driver `MapInfo File' successful.

Layer name: test2
Geometry: Point
Feature Count: 5
Extent: (102.703889, 28.926111) - (102.861389, 29.155000)
...
OGRFeature(test2):1
  Lxh (String) = 2001
  Dm (String) = 1
  Ydm (String) =
  Jdh (Real) = 1
  H85 (String) = 0
  B (Real) = 0.0000000000
  L (Real) = 0.0000000000
  Ly (String) =
  M (String) =
  Hgd (Real) = 0.0000000
  Style = SYMBOL(a:0,c:#f8188d,s:6pt,id:"mapinfo-sym-34,ogr-sym-3")
  POINT (102.703889 28.926111)
...