Closed JoerivanEngelen closed 1 year ago
Issue:
In certain cases an IndexError is thrown when calling xu.snap_to_grid
IndexError
xu.snap_to_grid
To reproduce:
hfb_debug2.zip
# %% Imports from pathlib import Path import geopandas as gpd import xugrid as xu # %% Path root = Path(r".") hfb_path = root / r"hfb_debug2\hfb.shp" target_path = root / r"hfb_debug2\target.nc" # %% Open lines = gpd.read_file(hfb_path) uda_target = xu.open_dataarray(target_path) # %% Snap target = uda_target.grid snapped = xu.snap_to_grid(lines, target, max_snap_distance=0.5)
This will throw: IndexError: index 720 is out of bounds for axis 0 with size 105
IndexError: index 720 is out of bounds for axis 0 with size 105
Debugging shows this happens in:
def _find_largest_edges( intersection_edges: FloatArray, segment_index: IntArray, edges: IntArray, line_index: IntArray, ): valid_edges = intersection_edges[segment_index] ...
Where segment_index contains indices ranging from 720 to 742, whereas intersection_edges only has a shape (105,).
segment_index
intersection_edges
Issue:
In certain cases an
IndexError
is thrown when callingxu.snap_to_grid
To reproduce:
hfb_debug2.zip
This will throw:
IndexError: index 720 is out of bounds for axis 0 with size 105
Debugging shows this happens in:
Where
segment_index
contains indices ranging from 720 to 742, whereasintersection_edges
only has a shape (105,).