Re: reading with a window doesn't honour window shape


Guillaume Lostis <guillaume@...>
 

Hi,

If you add `out_shape=(1200, 1200)` to your `read()` call it returns an array with the right shape. I don't know exactly why you need to specify this though.

Best,

Guillaume

Le ven. 15 janv. 2021 à 17:48, Paolo Corti <pcorti@...> a écrit :
Hi all

I have the following problem: I want to read a dataset using a window with a specific shape, but the window shape isn't always honored from the returned array.

You can replicate this problem using this dataset: https://www.worldpop.org/geodata/summary?id=6334

with rasterio.open(raster_pop_path) as src_pop:
window = Window(col_off=1470.4999917338748, row_off=2902.4961942222235, width=1200, height=1200)
pop_arr = src_pop.read(1, window=window)
print(pop_arr.shape)

print returns (1200, 1199) while it should be (1200, 1200)

Any idea why this could happen?
Thanks in advance

Paolo

--
Paolo Corti
Geospatial software developer
web: http://www.paolocorti.net
twitter: @capooti
skype: capooti
#drt3jc1

Join main@rasterio.groups.io to automatically receive all group messages.