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

Even Rouault even.rouault at spatialys.com
Fri Feb 28 07:51:39 PST 2020


Pedro,

> 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.

Arg, I found this was a bug of PROJ >= 6. I've just submitted a fix for it in 
https://github.com/OSGeo/PROJ/pull/1998
The issue came from using both +nadgrids and +pm, which wasn't handled 
correctly, and resulted in grid transformation being done with longitudes 
expressed in Lisbon prime meridan instead of Greenwich

> And where can I find documentation about the WKT2 string describing the
> CoordinateOperation to use in -ct?

Create coordinate operations in WKT2 can be really tedious. The best reference 
is probably the standard itself:
http://docs.opengeospatial.org/is/18-010r7/18-010r7.html

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list