2

I'm trying to convert some data from ESRI Shapefile to MapInfo TAB format using ogr2ogr. The data is projected using the British National Grid (EPSG:27700). The output file is valid, and the geometry and attribute data are OK, but the projection is incorrect. This is best illustrated with an example.

points

Start with a GeoJSON file containing a single point:

{
    "type": "FeatureCollection",
    "features": [{
        "type": "Feature",
        "properties": { "FID": 0 },
        "geometry":
        {
            "type": "Point",
            "coordinates": [ 393800.0, 212700.0 ]
        }
    }]
}

If I convert to an ESRI Shapefile (assigning a projection, as GeoJSON has none), everything works:

$ ogr2ogr test.shp test.geojson -a_srs EPSG:27700
$ gdalsrsinfo -o proj4 test.shp
'+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs '

QGIS expands +datum=OSGB36 to a 7 parameter transformation from WGS84, as so:

+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs

Next, I try to convert to MapInfo:

$ ogr2ogr test2.tab test.geojson -a_srs EPSG:27700 -f 'MapInfo File'
$ gdalsrsinfo -o proj4 test2.tab
'+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=375,-111,431,0,0,0,0 +units=m +no_defs '

The result is a 3 parameter transformation. The actual geometry is unmodified, and I can manually redefine the projection in QGIS, but this is not good.

Next, I try to reproject to a 3 parameter transform...

$ ogr2ogr test3.tab test.geojson -s_srs EPSG:27700 -t_srs '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=375,-111,431,0,0,0,0 +units=m +no_defs ' -f 'MapInfo File'
$ gdalsrsinfo -o proj4 test3.tab
'+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs '

It changed again! Finally, if I try to reproject once more:

$ ogr2ogr test4.tab test.geojson -s_srs EPSG:27700 -t_srs '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ' -f 'MapInfo File'
$ gdalsrsinfo -o proj4 test4.tab
'+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs '

This works - the geometry has been modified, but at least it is what it says it is.

But that's not what I want! How to I get the MapInfo file to store the 7 parameter transform?

This issue seems to be related to these questions, but as far as I can see they don't provide an answer. From what I can tell, either OGR is doing something wrong, or the MapInfo format simply can't handle this information. QGIS and MapInfo Projections - EPSG 27700 (British National Grid) Question about BNG coordinate systems

  • If you know the correct MapInfo projection string try to write out MID/MIF and edit the MIF file manually. With your command -a_srs epsgs:27700 I get there CoordSys Earth Projection 8, 79, "m", -2, 49, 0.9996012717, 400000, -100000 – user30184 Nov 7 '14 at 11:12
1

If you look inside http://trac.osgeo.org/gdal/browser/branches/1.11/gdal/ogr/ogrsf_frmts/mitab/mitab_spatialref.cpp you see:

{ 6277, 79, "OSGB_1936", 9, 375, -111, 431, 0, 0, 0, 0, 0},

The shift values were replaced in GDAL some time ago, but obviously not in the mitab driver.

Keep in mind that EPSG:27700 in the original EPSG definition does not obey any datum shift, instead there are several datum shifts from OSGB to WGS84 available. See this Q&A for all possible values: Raster incorrectly reprojected to OSGB(27700)

ESRI products follow that line and do not bundle datum shifts to projections, as you are used to in GDAL and QGIS.

I don't know how this is handled in Mapinfo, so I can not say it is a bug if the file gets a different datum shift information.

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.