Skip to content

Commit

Permalink
fix rasterio index issue; better fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hambsch committed Nov 29, 2024
1 parent 29deeee commit 9349ab3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/guppy/endpoints/endpoint_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from fastapi import HTTPException
from rasterio.mask import mask, raster_geometry_mask
from rasterio.windows import from_bounds
from rasterio.transform import rowcol
from sqlalchemy.orm import Session

from guppy.db import schemas as s
Expand Down Expand Up @@ -249,7 +250,7 @@ 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.rowcol([p[0] for p in coords], [p[1] for p in coords])
rows, cols = rowcol(src.transform, [p[0] for p in coords], [p[1] for p in coords])
cols = [c - geometry_window.col_off for c in cols]
rows = [r - geometry_window.row_off for r in rows]
in_rows = []
Expand Down

0 comments on commit 9349ab3

Please sign in to comment.