[gdal-dev] How to specify 'OUTPUT' when warping (reproject)
ky
rupestre.campos at gmail.com
Fri Oct 3 17:29:21 PDT 2025
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 <gdal-dev at lists.osgeo.org>
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,
> > <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
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20251003/9e17b80a/attachment.htm>
More information about the gdal-dev
mailing list