2

I am using gdalwarp in the commandline as so

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=hgridshift +grids=uk_os_OSTN15_NTv2_OSGBtoETRS.tif +step +proj=webmerc +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84" C:/testin.tif C:/test/out.tif

This command runs perfectly and gives the intended output. However, when I try to do this in python I get the error

ERROR: ('Cannot instantiate pipeline +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=hgridshift +grids=uk_os_OSTN15_NTv2_OSGBtoETRS.tif +step +proj=webmerc +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84',)

My code looks like so:

try:
            kwargs = {'coordinateOperation': "+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=hgridshift +grids=uk_os_OSTN15_NTv2_OSGBtoETRS.tif +step +proj=webmerc +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84"}

            input_raster = gdal.Open(tif_in)
            
            self.reprojected_tif = tif_out + "_reprojected.tif"
            warp = gdal.Warp(self.reprojected_tif, input_raster, **kwargs)
            warp.FlushCache() 

What would be causing the above error in python when it runs ok in the GDAL command window?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.