This part can probably be skipped:
|
within = gpd.sjoin(gdf_result, boundary_gdf, predicate="intersects") |
|
mask_inside = gdf_result.index.isin(within.index) |
|
|
|
# Nearest-neighbor fallback for NaN points inside the boundary |
|
mask_nan_inside = mask_inside & np.isnan(interpolated) |
|
if mask_nan_inside.any(): |
|
nearest = griddata(src_xy, src_values, all_xy[mask_nan_inside], method="nearest") |
|
interpolated[mask_nan_inside] = nearest |
|
|
|
gdf_result["value"] = interpolated |
|
|
|
# Clip: set values outside boundary to NaN |
|
gdf_result.loc[~mask_inside, "value"] = np.nan |
reasons: griddata automatically creates a convex hull when using 'linear' and clipping to boundary_gdf is not strictly necessary. Within convex hull interpolation result will be used, outside of it values from REGIS will be used. Lines will be removed after testing if the interpolation result is indeed as envisaged.
This part can probably be skipped:
data/src/nhflodata/data/mockup/bodemlagen_pwn_2024/v2.0.0/botm/interpolation_helper_functions.py
Lines 866 to 878 in 882a24d
reasons: griddata automatically creates a convex hull when using 'linear' and clipping to boundary_gdf is not strictly necessary. Within convex hull interpolation result will be used, outside of it values from REGIS will be used. Lines will be removed after testing if the interpolation result is indeed as envisaged.