[gdal-dev] gdal.Warp behaves differently comparing to gdalwarp

Denis Rykov rykovd at gmail.com
Fri Aug 5 07:57:28 PDT 2022


ds_img.FlushCache() did the trick!

On Fri, Aug 5, 2022 at 4:44 PM Denis Rykov <rykovd at gmail.com> wrote:

> Hi,
>
> I would expect these 2 ways of running GDAL warp should produce the same
> results.
>
> gdalwarp -t_srs EPSG:3857 \
>          -te 558728 5789851 1242296 7544030 \
>          -ts 500 500 \
>          "WMS:
> http://127.0.0.1:8080/api/resource/5840/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=test_rounds&SRS=EPSG:4326&BBOX=-180.000000,-85.051129,180.000000,85.051129"
> \
>          /tmp/result1.tif
>
> and
>
> from osgeo import gdal
> from osgeo import gdalconst
>
> width = height = 500
> url = "WMS:
> http://127.0.0.1:8080/api/resource/5840/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=test_rounds&SRS=EPSG:4326&BBOX=-180.000000,-85.051129,180.000000,85.051129
> "
> ds = gdal.Open(url, gdalconst.GA_ReadOnly)
> ds_img = gdal.Warp(
>     "/tmp/result2.tif",
>     ds,
>     options=gdal.WarpOptions(
>         width=width,
>         height=height,
>         outputBounds=(558728, 5789851, 1242296, 7544030),
>         dstSRS="EPSG:3857",
>     ),
> )
>
> But in the first case I get what I expect but in the second one I get a
> raster with right spatial extent but 0 in all bands.
>
> What am I missing?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220805/f910da3f/attachment.htm>


More information about the gdal-dev mailing list