Topics

Does rasterio.warp.reproject use overviews?


Loïc Dutrieux
 

Hi everyone,


I read that the gdalwarp command line defaults to using the overview level nearest to target resolution. What about `rasterio.warp.reproject()`? Does it use overview at all?


Thank you and kind regards,

Loïc


Sean Gillies
 

Hi Loïc,

On Tue, Nov 3, 2020 at 8:55 AM Loïc Dutrieux <loic.dutrieux@...> wrote:

Hi everyone,


I read that the gdalwarp command line defaults to using the overview level nearest to target resolution. What about `rasterio.warp.reproject()`? Does it use overview at all?


Thank you and kind regards,

Loïc

gdalwarp's logic is found in apps/gdalwarp_lib.cpp, not in gcore, so rasterio.warp.reproject() does not have it. We've got a rasterio ticket about switching over to use the main function in apps/gdalwarp_lib.cpp so that the behavior of rasterio.warp.reproject() is exactly the same as gdalwarp, but haven't started work on it yet.

--
Sean Gillies


Loïc Dutrieux
 

Hi Sean,


Thank you for your response.

Is it correct to interpret from your explanation that:

 1- currently the reproject function will never use overviews of the source file, even when it involves downsampling.

 2- In a future version `reproject()` will eventually use source file overviews. (and the user will be able to control that behavior via an argument (e.g. overviewLevel= as in gdal python API)?)


To provide some context about why I want to know that, I'm warping 10 m sentinel2 data to a 20 m grid and I want to make sure it does *not* use the source file overviews. Overviews are fine for visualization but often not suitable for analysis (unless they have been generated with the right resampling algorithm).


Thanks again,

Cheers,

Loïc




From: main@rasterio.groups.io <main@rasterio.groups.io> on behalf of Sean Gillies <sean.gillies@...>
Sent: 05 November 2020 16:27:12
To: main@rasterio.groups.io
Subject: Re: [rasterio] Does rasterio.warp.reproject use overviews?
 
Hi Loïc,

On Tue, Nov 3, 2020 at 8:55 AM Loïc Dutrieux <loic.dutrieux@...> wrote:

Hi everyone,


I read that the gdalwarp command line defaults to using the overview level nearest to target resolution. What about `rasterio.warp.reproject()`? Does it use overview at all?


Thank you and kind regards,

Loïc

gdalwarp's logic is found in apps/gdalwarp_lib.cpp, not in gcore, so rasterio.warp.reproject() does not have it. We've got a rasterio ticket about switching over to use the main function in apps/gdalwarp_lib.cpp so that the behavior of rasterio.warp.reproject() is exactly the same as gdalwarp, but haven't started work on it yet.

--
Sean Gillies


Sean Gillies
 

Loïc,

1. Correct. To use overviews, you must pass a dataset explicitly opened on an overview using `rasterio.open("example.tif", OVERVIEW_LEVEL=1)`.
2. Correct again. We'll add an option to use an automatically determined source file overview, as gdalwarp does.


On Thu, Nov 5, 2020 at 10:29 AM Loïc Dutrieux <loic.dutrieux@...> wrote:

Hi Sean,


Thank you for your response.

Is it correct to interpret from your explanation that:

 1- currently the reproject function will never use overviews of the source file, even when it involves downsampling.

 2- In a future version `reproject()` will eventually use source file overviews. (and the user will be able to control that behavior via an argument (e.g. overviewLevel= as in gdal python API)?)

To provide some context about why I want to know that, I'm warping 10 m sentinel2 data to a 20 m grid and I want to make sure it does *not* use the source file overviews. Overviews are fine for visualization but often not suitable for analysis (unless they have been generated with the right resampling algorithm).


Thanks again,

Cheers,

Loïc




From: main@rasterio.groups.io <main@rasterio.groups.io> on behalf of Sean Gillies <sean.gillies@...>
Sent: 05 November 2020 16:27:12
To: main@rasterio.groups.io
Subject: Re: [rasterio] Does rasterio.warp.reproject use overviews?
 
Hi Loïc,

On Tue, Nov 3, 2020 at 8:55 AM Loïc Dutrieux <loic.dutrieux@...> wrote:

Hi everyone,


I read that the gdalwarp command line defaults to using the overview level nearest to target resolution. What about `rasterio.warp.reproject()`? Does it use overview at all?


Thank you and kind regards,

Loïc

gdalwarp's logic is found in apps/gdalwarp_lib.cpp, not in gcore, so rasterio.warp.reproject() does not have it. We've got a rasterio ticket about switching over to use the main function in apps/gdalwarp_lib.cpp so that the behavior of rasterio.warp.reproject() is exactly the same as gdalwarp, but haven't started work on it yet.

--
Sean Gillies



--
Sean Gillies