GDAL version 3 and higher does not work with Mapinfo and Decimal Fields

112 views Asked by At

I'm having a problem trying to convert a MapInfo file from MID/MIF format to TAB format. This problem occurs from version GDAL 3.0.4 and higher. On version 2.1.2, everything works without problems.

I use the following command

ogr2ogr -f "MapInfo file" "test.tab" "test.mif"

Error following

ERROR 1: Cannot format 1234.1 as a 20.16 field ERROR 3: Failed writing attributes for feature id 1 in test.tab ERROR 1: Unable to write feature 1 from layer test. ERROR 1: Terminating translation prematurely after failed translation of layer test (use -skipfailures to skip errors)

Here example of MapInfo file MID/MIF format

test.mif

test.mid

Can anyone explain what is the reason for this error?

Im trying to use GDAL version 3.5, but still getting this error.

If I change the column type to Float than everything works fine.

But I can't just change the format of the existing file

1

There are 1 answers

1
Bo Victor Thomsen On BEST ANSWER

Your value "1234.1" is to big.

From the documentation:

Decimal fields store single and double precision floating point values. Width is the total number of characters allocated to the field, including the decimal point. Precision controls the precision of the data and is the number of digits to the right of the decimal.

Your decimal definition "Decimal (20,16)" leaves only 3 digits for the integer part. Try a lesser value, i.e: 999.4 or change the decimal format to Decimal (20,15)