Hi Ky,
I'm beginning to understand this a bit better. My original code actually passed the raster layer per se (rather than the tiff file) so that explains the previous error. After fixing it, QGIS is now reprojecting into the new CRS but, for some reason that I still need to troubleshoot, it's cropping the western side of the layer (the central and eastern side are fine) -this is hard to explain with words but easy to see with images-. Will let you know if any other issue comes up or if it finally works as anticipated.
Thanks.

On 2025-10-04 00:29, ky wrote:
I believe you should check what is inside my_input_raster_layer, there
should be a path to a input raster file like

gdal.Warp("output.tif", "input.tif", options=options)

On Fri, Oct 3, 2025 at 7:44 PM AF via gdal-dev
<[email protected]> wrote:

Hi Nyall,
It was a typo (pretty clumsy at my end) as it should have read
'my_input_raster_layer' rather than 'my_input_vector_layer.' The
source/input layer is a raster.
Thanks.

On 2025-10-03 21:30, Nyall Dawson wrote:
On Sat, 4 Oct 2025, 2:00 am AF via gdal-dev,
<[email protected]> wrote:

Hello,
A PyQGIS code needs to reproject one raster layer from a CRS to a
new
one. To begin with, I've tried to use only the minimal required
options
so the snippet reads:
parameters = {
'INPUT': my_input_vector_layer,

Not sure if this is a typo (or a badly named variable, or ai slop
code), but it looks like you're trying to warp a vector later to a
raster layer? 🤔

Nyall

'SOURCE_CRS':
QgsCoordinateReferenceSystem(source_PROJ),
'TARGET_CRS':
QgsCoordinateReferenceSystem(target_PROJ),
'RESAMPLING': 1,
'DATA_TYPE': 4,
'OUTPUT': '/home/ubuntu/my_new_raster.tif'
}
terrain = processing.run('gdal:warpreproject',
parameters)
However, this doesn't do much as terrain is simply a dictionary
with
the
keyword 'OUTPUT' and my_new_raster.tif is never created.
Obviously I

must be doing something wrong and suspect that might be related
to
'OUTPUT'. The documentation at



https://docs.qgis.org/testing/en/docs/user_manual/processing/toolbox.html#output-parameter-widget

didn't dissipate my doubts so I'm unsure how to proceed.
I also tried (an alternative method) calling gdal.Warp directly
(not

sure if this method is preferable to using processing.run) but it
keeps
saying that it only takes 2 arguments. I found a few examples
online
but
they all have more than 2 arguments. For example
options = gdal.WarpOptions(dstSRS=target_PROJ)
warp = gdal.Warp('/home/ubuntu/pepe.tif',
my_input_vector_layer, options)
warp = None
complains about including 3 and not 2 arguments. Same if I try
including
all arguments at warp.
Thanks.
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to