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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Pedro Venâncio-2
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


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

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: ogr2ogr command to coordinate transform using NTv2 grids in GDAL 3+

Even Rouault-2
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
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: ogr2ogr command to coordinate transform using NTv2 grids in GDAL 3+

Pedro Venâncio-2
Thank you very much Even!

As usual, faster fix was completely impossible! :)

Best regards,
Pedro


Even Rouault <[hidden email]> escreveu no dia sexta, 28/02/2020 à(s) 15:51:
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

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev