Skip to content

Commit

Permalink
revert to default interpolation of river values being included into a…
Browse files Browse the repository at this point in the history
… hydrologicaly conditioned DEM, but also update dynamically to support interpolation from fewer points if less supplied
  • Loading branch information
rosepearson committed Sep 12, 2024
1 parent 4396869 commit e967cbf
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/geofabrics/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ def interpolate_rivers(
elevations: geometry.EstimatedElevationPoints,
method: str,
cache_path: pathlib.Path,
k_nearest_neighbours: int = 5,
k_nearest_neighbours: int = 100,
) -> xarray.Dataset:
"""Performs interpolation from estimated bathymetry points within a polygon
using the specified interpolation approach after filtering the points based
Expand Down Expand Up @@ -1331,6 +1331,19 @@ def interpolate_rivers(
json.dumps(pdal_pipeline_instructions), [edge_points]
)
pdal_pipeline.execute()

if len(river_points) < k_nearest_neighbours or len(edge_points) < k_nearest_neighbours:
logging.info(
f"Fewer river or edge points than the default expected {k_nearest_neighbours}. "
f"Updating k_nearest_neighbours to {min(len(river_points), len(edge_points))}."
)
k_nearest_neighbours = min(len(river_points), len(edge_points))
if k_nearest_neighbours < 3:
logging.warning(
f"Not enough river or edge points to meaningfully include {k_nearest_neighbours}. "
f"Exiting without including the river and edge points."
)
return

if self.chunk_size is None:
logging.warning("Chunksize of none. set to DEM shape.")
Expand Down

0 comments on commit e967cbf

Please sign in to comment.