GDAL Coordinate Transformation – Aligning with QGIS Coordinate Transformation

coordinate systemgdalgdalwarpqgis

I have a raster being changed from EPSG:27700 to EPSG:3857 coordinate reference system.

Within the QGIS application, I have found this coordinate transformation to fit the best

enter image description here

I've tried to replicate this coordinate transformation in GDAL and assumed that by declaring -ct "+proj=pipeline +step +inv +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +step +proj=push +v_3 +step +proj=cart +ellps=airy +step +proj=helmert +x=371 +y=-111 +z=434 +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=webmerc +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84" as per the QGIS window, I'd get the same result. Sadly not. Using GDAL and this -ct my raster is ending up on the coast of Alaska when it should be in the UK.

What am I doing wrong?

This is the GDAL command I was using

gdalwarp -ct "+proj=pipeline +step +inv +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +step +proj=push +v_3 +step +proj=cart +ellps=airy +step +proj=helmert +x=371 +y=-111 +z=434 +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=webmerc +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84" C:/new/DensA_20210506.tif C:/new/DensA_20210506_gdal.tif

Best Answer

When applying a set of transformations and/or conversions through a PROJ pipeline inside the -ct parameter of gdalwarp, the coordinates of the pixels are changed, but not the reference system of those coordinates.

In order for the new coordinates to correspond to the same location on Earth as the previous ones, the target Spatial Reference System must also be modified through the -t_srs parameter.

The source geospatial location was already defined in the source file, through a geotransform matrix or control points, referenced to a source SRS. The set of operations from the source (in the file) to the destination (in the -t_srs parameter) SRS is overwritten with the -ct command, avoiding the search of the default operation within the PROJ database.

Therefore, to custom transform to a new SRS, it is necessary to define both -ct and -t_srs parameters on the gdawarp command line.

Related Question