Re: Is it possible to ignore existing overview when performing decimated read?

Loïc Dutrieux

Hi Denis,

Thanks for pointing to that issue. I may have misunderstood it but I don't think it helps answering my question.

From: <> on behalf of Denis Rykov <>
Sent: 10 November 2020 21:36:13
Subject: Re: [rasterio] Is it possible to ignore existing overview when performing decimated read?

You can find an example how to do that here:<;!!DOxrgLBm!XaInc3_J0VCLXQo6gYXo0rBWHs4b0p4ZkMuimU2g9HtJy0eRb55BN-J7JDPt-MB3Dhg5K3E$>.

On Tue, Nov 10, 2020, 8:12 PM Loïc Dutrieux <<>> wrote:
Hi everyone,

I'm trying to perform a decimated read of a dataset that already contains overviews. Regardless of which value I pass to the resampling= argument of the read method, it seems that the already existing overview is used. Is there any way to ignore it? See the reproducible example below.



import tempfile
import os

import numpy as np
import rasterio
from rasterio.enums import Resampling

filename = os.path.join(tempfile.gettempdir(), 'overview_test.tif')

# Create random int array
shape = (100, 100)
arr = np.random.randint(0, 9999, size=shape, dtype=np.uint16)

meta = {'height': 100,
'width': 100,
'driver': 'GTiff',
'dtype': np.uint16,
'count': 1}

# Write random array to file and compute first overview
with, 'w', **meta) as dst:
dst.write(arr, 1)
dst.build_overviews([2], Resampling.nearest)

# Read with downsample
with as src:
arr_avg =, out_shape=(1,50,50), resampling=Resampling.average,
arr_nrt =, out_shape=(1,50,50), resampling=Resampling.nearest)

print(np.max(arr_avg - arr_nrt))
# when the source file does not contain overviews, the max of the difference array
# is > 0

Join to automatically receive all group messages.