[gdal-dev] ogr2ogr command to coordinate transform using NTv2 grids in GDAL 3+

Pedro VenĂ¢ncio pedrongvenancio at gmail.com
Fri Feb 28 06:28:26 PST 2020


Dear all,

I'm trying to make transformations with ogr2ogr, using NTv2 grids, in
GDAL/OGR 3, and it does not work.

The command I was using in GDAL/OGR 2 is

ogr2ogr -s_srs "+proj=tmerc +lat_0=39.66666666666666 +lon_0=1 +k=1
+x_0=200000 +y_0=300000 +ellps=intl
+nadgrids=C:\Users\PedroVenancio\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ntv2_transformations\grids\DLx_ETRS89_geo.gsb
+wktext +pm=lisbon +units=m +no_defs" -t_srs EPSG:3763 -f "ESRI Shapefile"
-lco ENCODING=UTF-8
D:/Testes/postos_vigia/postos_vigia_rede_nacional_3763.shp
D:\Testes\postos_vigia\postos_vigia_rede_nacional_20790.shp

and the result in GDAL/OGR 3.0.2 or 3.0.4 is

ERROR 1: Failed to reproject feature 0 (geometry probably out of source or
destination SRS).
ERROR 1: Terminating translation prematurely after failed
translation of layer postos_vigia_rede_nacional_20790 (use -skipfailures to
skip errors)

This command works well in GDAL/OGR 2.4.0 and 2.4.2.

Looking at the ogr2ogr documentation, I've found the new -ct option

https://gdal.org/programs/ogr2ogr.html#cmdoption-ogr2ogr-ct

So, I can run the transformation in GDAL/OGR 3, with the command

ogr2ogr -s_srs EPSG:20790 -t_srs EPSG:3763 -ct "+proj=pipeline +step +inv
+proj=tmerc +lat_0=39.6666666666667 +lon_0=1 +k=1 +x_0=200000 +y_0=300000
+ellps=intl +pm=lisbon +step +proj=hgridshift +grids=DLx_ETRS89_geo.gsb
+step +proj=tmerc +lat_0=39.6682583333333 +lon_0=-8.13310833333333 +k=1
+x_0=0 +y_0=0 +ellps=GRS80" -f "ESRI Shapefile" -lco ENCODING=UTF-8
D:/Testes/postos_vigia/postos_vigia_rede_nacional_3763_17.shp
D:\Testes\postos_vigia\postos_vigia_rede_nacional_20790.shp

I've get the -ct string from QGIS and it works as expected, but the command
becomes much more complex and not compatible with GDAL/OGR 2.x versions.

Is this the only and best way to make this operation, with NTv2 grids, in
GDAL/OGR 3?

And where can I find documentation about the WKT2 string describing the
CoordinateOperation to use in -ct? I can always use QGIS, but it is not
very handy, and I suspect that I'm not using the best approach.

Thank you very much!

Best regards,
Pedro VenĂ¢ncio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200228/bb8ab169/attachment.html>


More information about the gdal-dev mailing list