A Rasterio dataset's index()
method gives you the row, col
index of the pixel containing the point x, y
(in the dataset's CRS units).
Define a 1x1 pixel read window starting at that index (see the tiny_window()
function below) and use it to read an ndarray. The one in this case has shape (3, 1, 1)
: 3 bands, 1 row, and 1 column. The values of the 3 bands at the point x, y
for this case are 28, 29, and 27.