-
I have a 10x10 (with four bands) GeoTIFF that I want to tile into 3x3 tiles. When the window gets to the edge of the image, I want to get a 3x3 tile padded with NaNs. When I try to use the import rioxarray
from rasterio.windows import Window
img_arr = rioxarray.open_rasterio("../data/10x10.tif")
n_bands, y_max, x_max = img_arr.shape # (4, 10, 10)
height, width = 3, 3
for y in range(0, y_max, height):
for x in range(0, x_max, width):
window = Window(col_off=x, row_off=y, width=width, height=height)
tile = img_arr.rio.isel_window(window=window, pad=True)
print(f"{y=} {x=} {tile.shape=}")
As you can see, every time I feel like I am missing something obvious, but I am not seeing it. |
Beta Was this translation helpful? Give feedback.
Answered by
snowman2
Feb 17, 2022
Replies: 1 comment 1 reply
Answer selected by
deppen8
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#155 and #383 might be relevant