[gdal-dev] How to specify 'OUTPUT' when warping (reproject)
afernandez at odyhpc.com
afernandez at odyhpc.com
Fri Oct 3 15:43:45 PDT 2025
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,
> <gdal-dev at lists.osgeo.org> 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
>> gdal-dev at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/gdal-dev
More information about the gdal-dev
mailing list