Skip to content

[Feature]: Water on the relief: lakes drawn flat at their level, without the relief's light, with a soft sun glint #1915

Closed

Description

@elpidioassinaturas

Problem

Water bodies on a relief map are drawn today as an ordinary polygon layer over the Shaded Relief or the draped terrain:

  • Tilted views raise the water with the DEM. Global DEMs such as Copernicus GLO-30 are surface models, often noisy or stepped over water, so a reservoir ripples and tilts with them. A polygon draped over the terrain follows every bump.
  • The relief's light reaches the water. With a semi-transparent water fill, or a fill blended with the relief (layer.blend), the hillshade and cast shadows (feat(raster): Shaded Relief casts soft shadows (#1782, part 1) #1796) show through, and the lake gets slopes and shadows it doesn't have.
  • Nothing tells water from land but the colour. Relief tools (rayshader's add_water and its water rendering) draw water flat, unlit by the terrain, with a little shine from the sun. That is what makes a lake read as water at a glance.

Proposal

A water option on the terrain (map.terrain "water": {"layer": "lagos", ...}, off by default), naming a polygon layer:

  • Flat at its level. Inside each polygon, the terrain's height (terrain::Ground) is the polygon's level: the lowest DEM height along its outline (the shore), or a numeric field given as "level". Tilted views then draw the lake flat, and the shore meets the land.
  • Not lit by the relief. Shaded Relief draws the water's cells with a fixed light, the flat ground's own, with no hillshade or cast shadow. The water layer's own symbology gives its colour as usual.
  • A soft glint. A tilted view adds a highlight where the sun would reflect toward the eye, broad and faint ("glint", 0 to 1, default 0.3), so the water shines a little on the sun's side.
  • A darker shore band a few pixels wide inside the outline, as relief artists draw it ("shore", on by default when water is set).

Choices in this proposal

  • Water from a polygon layer, not detected from the DEM. Real water bodies exist as data (national hydrography, OpenStreetMap). Detecting flat cells, as rayshader's detect_water does, also takes floodplains, airfields and flat roofs for lakes. Detection could follow as a tool that writes such a layer.
  • The level from the shore's lowest height. It is the water's surface where the DEM is right, at the edge. A field overrides it for a reservoir with a known level.
  • Rivers stay lines. A line layer is already drawn over the relief. Flattening a river's corridor would need its width, which a line doesn't have.
  • Off by default. Nothing changes for existing maps.

Not measured

I haven't prototyped this. The costs to check are reading each water polygon's level once, when the layer or the terrain changes, and a point-in-polygon test per mesh vertex and per cell. For both, a rasterised mask at the DEM's resolution would keep the per-cell test to a lookup.

Alternatives considered

  • Bathymetry under the water, with depth tints. It needs depth data most users don't have. It could build on this later.
  • Doing it all in the water layer's symbology. The layer can't flatten the terrain or stop the relief's light: both belong to the terrain and the relief.

🤖 Generated with Claude Code

Activity

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

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