1

I have GeoPackage file, I tried to convert tab format

Layer right click >> Export >> Save features as >> Selected map info and other options

It's exported successfully. But some features not equal with original GeoPackage(executed the select by location with equal condition). At 1:1 scale, features have gap.

Used projection: Espg:4283

Why this behaviour there for tab and how can I solve this issue?

For other formats(.shp, .gpkg) it gives expected result.

Tried with code:

x=150.8244469

y=-33.835027

l=iface.activeLayer()

feat=QgsFeature(l.fields())

g=QgsGeometry.fromPointXY(QgsPointXY(x,y))

feat.setGeometry(g)

l.addFeature(feat)

l.commitChanges()
2
  • 2
    Hard to say without test data. MapInfo stores coordinates as integers with a bit peculiar precision model groups.google.com/g/mapinfo-l/c/hIl5kA1EAhM. It may be that GDAL finds unsuitable bounds or coordinate system.
    – user30184
    Commented Mar 28, 2023 at 12:08
  • you can randomly generate points geopack and export to mapinfo it will have same behaviour, some times near feature exactly expoterd, some are moved Commented Mar 28, 2023 at 12:36

1 Answer 1

6

The issue is caused by the MapInfo TAB format itself and it is a documented behavior of the GDAL Tab driver https://gdal.org/drivers/vector/mitab.html#creation-issues

The TAB File format requires that the bounds (geographical extents) of a new file be set before writing the first feature.

There is currently no automated setting of valid default bounds for each spatial reference system, so for the time being, the MapInfo driver sets the following default bounds when a new layer is created:

  • For a file in LAT/LON (geographic) coordinates: BOUNDS (-180, -90) (180, 90)

  • For any other projection: BOUNDS (-30000000 + false_easting, -15000000 + false_northing) (30000000 + false_easting, 15000000 + false_northing)

It is possible to override those bounds through two mechanisms. ...

Coordinates are stored into tab file as integers. The size of the resolution unit is (maxX - minX)/2000000000. For a projected coordinate system the formula gives

(30000000 - -30000000)/2000000000=0.03

It means that with the default settings the shortest possible distance in x-direction between two distinct points in the TAB file is 3 centimeters. Therefore when saving data from QGIS the vertices may move by 1.5 centimeters at maximum.

If you know that the layer does not cover the whole world it is possible to increase the resolution by decreasing the bounds of the TAB file. The place to write the strict min/max values in the QGIS user interface is here. The values can be copied from the layer extents.

enter image description here

With Python read the alternative ways for defining the bounds from the driver manual https://gdal.org/drivers/vector/mitab.html#creation-issues. The MapInfo MID/MIF format does suffer from this inbuild feature of the TAB format.

See also https://groups.google.com/g/mapinfo-l/c/hIl5kA1EAhM

I have found this formula: MapInfo stores all coordinates internally as long integers ranging from -1 billion to +1 billion. These internal coordinates are translated into "coordinate system" coordinates by applying two linear transformations - - one for the X coordinate and another for the Y. The coefficients of these linear transformations are determined from the bounds of the coordinate system.

For example, say you specify a bounds of (20000,100000) to (50000,110000) in meters. Along the X axis, you have a range of 30000 meters, so MapInfo's precision along that axis will be 30000 / 2 billion = 0.000015 meter. Along the Y axis, you have a range of 10000 meters, so the precision along that axis will be 10000 / 2 billion = 0.000005 meter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.