Skip to content

Use griddata's convex hull to determine the valid interpolation range #59

Description

@vincentpost

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions