From 23b9eef9149a4b8e4241c601e1d00847774f8b3d Mon Sep 17 00:00:00 2001 From: Lorenz Hambsch Date: Fri, 29 Nov 2024 16:02:04 +0100 Subject: [PATCH] fix rasterio index issue --- server/guppy/endpoints/endpoint_utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/guppy/endpoints/endpoint_utils.py b/server/guppy/endpoints/endpoint_utils.py index 42c382a..21274d5 100644 --- a/server/guppy/endpoints/endpoint_utils.py +++ b/server/guppy/endpoints/endpoint_utils.py @@ -249,7 +249,12 @@ def sample_coordinates_window(coords_dict, layer_models, bounds, round_val=None) coords.extend(v) with rasterio.open(path) as src: geometry_window = from_bounds(bounds[0], bounds[1], bounds[2], bounds[3], src.transform).round_offsets() - rows, cols = src.index([p[0] for p in coords], [p[1] for p in coords]) + rows = [] + cols = [] + for x, y in zip([p[0] for p in coords], [p[1] for p in coords]): + row, col = src.index(x, y) + rows.append(row) + cols.append(col) cols = [c - geometry_window.col_off for c in cols] rows = [r - geometry_window.row_off for r in rows] in_rows = []