Skip to content

16c: a land-cover class per triangle, natural colours - #109

Merged
skavhaug merged 7 commits into
masterfrom
increment16c-landcover-labels
Sep 29, 2026
Merged

skavhaug merged 7 commits into
masterfrom
increment16c-landcover-labels

Conversation

@skavhaug

Copy link
Copy Markdown
Member

Increment 16c: a land-cover class per triangle, and natural colours for viewing. Design: docs/increments/16c-landcover-labels.md; acceptance: docs/benchmarks/2026-09-29/bygdin-landcover.md.

What it does

  • With a coded class map (e.g. --features-map corine), each triangle gets the class of the input polygon it lies in. Triangles are grouped across edges that are not constraints (union-find), and each group is tested once against the polygons (shapely). The class is 0 on constraint lines and outside every polygon. Where polygons overlap, the smallest wins; the result is deterministic.
  • .vtk: an int cell array land_cover_code on every cell, plus a land_cover_codes field naming the code system. .ply: an int land_cover_code face property.
  • rasputin palette corine --out corine_natural.json writes a ParaView preset with natural colours for all 44 CORINE classes (forests green, heath light green, rock grey, bogs brown, water blue, glaciers near white).
  • A polygon covering the whole domain is now kept, not dropped.

Numbers (AC, M1 Max)

Bygdin's catchment at 10 m with the Norway CORINE extract: 83 171 triangles, all labelled; class shares equal CORINE's clipped areas within 10⁻⁶ percentage points; the centroid oracle agrees on every triangle at 10 m and 1 m. Labelling takes 0.07 s at 10 m and 1.3 s at 1 m (more than refine at 1 m, which the design names as the trigger for moving it to C++ later).

Size

Net +249 production lines (CLAUDE.md §2).

Defaults chosen overnight are listed in the design for Ola to confirm.

🤖 Generated with Claude Code

skavhaug and others added 7 commits September 29, 2026 02:57
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The red suite of docs/increments/16c-landcover-labels.md, tests only:

- test_landcover.py: regions and label_triangles on hand-made grid meshes
  (no _core call): the design's fixtures as pure meshes, D2's overlap rule,
  determinism under permutation, thin slivers; I1 and the centroid oracle
  (I2) on every fixture.
- test_cli_mesh_landcover.py: the same fixtures through rasputin mesh on
  the bumpy DEM with I1-I3, the land_cover_codes field, the stderr line and
  stats phase, refused codes, no labels without a coded map, the PLY face
  property, a VTK readback, palette --out, and R5's feature_input fields.
- test_palettes.py: every CLC class, the 34 Norway codes and 0 coloured;
  families by hue ranges; the ParaView preset; the palette command.
- test_io_vtk_legacy.py / test_io_ply.py: triangle_codes and face_codes.
- test_cli_mesh_features.py::TestCommittedExtract: I1-I3 and I5 on the
  quarter circle against shapely clips of the extract.
- landcover_fixtures.py: the oracle, the spread check, vtk_labels.

Every new test fails on a missing module, parameter, array or behaviour;
the rest of the suite, ruff and mypy are green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Makes the red suite of 196147e pass; no test file touched.

- landcover.py: regions (edge keys, np.isin, array union-find to a fixed
  point) and label_triangles (largest-inradius incentre per component,
  STRtree lookup, smallest area then smaller code), CoverLabels counts.
- palettes.py: CORINE_NATURAL (44 CLC classes and 0) and paraview_preset.
- feature_input.py: ClassMap.codes; TerrainFeature.code and .polygon for a
  coded map; codes refused outside 1 .. 2**31 - 1; a coded polygon with no
  boundary in the domain kept with no lines when it covers it.
- io/vtk_legacy.py: triangle_codes -> cell array land_cover_code (0 on
  lines) in the features FIELD block; land_cover_codes joins RESERVED and
  its text arrives as the new parameter land_cover_codes.
- io/ply.py: face_codes -> face property int land_cover_code; the comment
  comes from the CLI through comments.
- cli.py: the land cover phase and stderr line, the codes to both writers,
  the palette command, one help sentence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… structure

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@skavhaug
skavhaug merged commit 340e7a8 into master Sep 29, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant