Skip to content

aggregate_vector_per_cell: support grouping per feature (by=['cellid', boundname]) #589

Description

@bdestombe

nlmod.grid.aggregate_vector_per_cell groups by cellid only, so pieces of different features that share a cell are always merged. For boundary conditions that need per-feature budgets/boundnames (e.g. one RIV reach per lake per cell), the aggregation should first merge pieces of the same feature within a cell and keep features separate.

Current workaround in NHFLO/tools: nhflotools.lakes._aggregate_lake_cells loops groupby('identificatie') and calls aggregate_vector_per_cell once per feature — functional but O(n_features) calls and not reusable.

Proposal: a by= parameter, default 'cellid' (backward compatible), accepting ['cellid', '<boundname column>'] so the per-feature step becomes a one-liner. Related: #582 moves the lake piece→cell aggregation into lake_from_gdf; this issue is the generic primitive underneath it.

Metadata

Metadata

Assignees

No one assigned

    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