Skip to content

Add real building heights for Spain from the Cadastre (Catastro)#1089

Open
pcturnes wants to merge 1 commit into
louis-e:mainfrom
pcturnes:feat/catastro-building-heights
Open

Add real building heights for Spain from the Cadastre (Catastro)#1089
pcturnes wants to merge 1 commit into
louis-e:mainfrom
pcturnes:feat/catastro-building-heights

Conversation

@pcturnes

@pcturnes pcturnes commented Jun 2, 2026

Copy link
Copy Markdown

Add real building heights for Spain from the Cadastre (Catastro)

What

Optional feature that replaces the default fallback building height with the
real number of floors from the Spanish Cadastre (Catastro), for buildings in
Spain that have no height in OpenStreetMap.

Why

Arnis derives building height from the OSM building:levels/height tags. When
neither is present it uses a fixed default, so in Spain — where most OSM
buildings lack those tags — urban areas generate as uniform flat boxes.

How

  • New --catastro CLI flag and a GUI toggle "Real heights (Spain / Catastro)"
    (off by default).
  • Fetches bu:BuildingPart features (numberOfFloorsAboveGround) from the
    Catastro INSPIRE Buildings WFS (ovc.catastro.meh.es/INSPIRE/wfsBU.aspx) for
    the generation bbox.
  • Downloads via a 6×6 tile grid with quadtree subdivision on truncation/timeout
    (the service caps response size and rejects very large bboxes).
  • Matches each Cadastre part to the OSM building it overlaps most (using the
    geo crate) and injects a building:levels tag into the raw OSM data before
    parsing
    , so the existing height/roof/window logic is reused unchanged.
  • New dependency: roxmltree (GML parsing).

Scope / limitations

  • Spain only; excludes the Basque Country and Navarra, which run their own
    cadastre and are not served by this WFS.
  • Off by default. Degrades gracefully: outside Spain or on a service failure the
    world is generated with the usual defaults (a warning is printed).
  • Assigns the floor count of the dominant overlapping part per OSM building
    (one height per footprint).
  • Building multipolygon relations are not enriched yet.
  • Heights follow Arnis' existing levels → blocks formula.

Testing

Verified on central Madrid (Basílica de San Francisco el Grande, ~3 km²):
1311 / 1330 buildings without a prior height enriched (98.6% coverage),
with a realistic floor distribution (peak at 5–6 floors, up to 14). Smaller
areas reach ~100%. cargo fmt and cargo clippy are clean.

Notes

The WFS download adds time proportional to the area (a few minutes for several
km²). A per-area cache would be a natural follow-up.


🤖 Generated with Claude Code

Buildings without a `building:levels`/`height` tag in OSM fall back to a
fixed default height. In Spain most OSM buildings lack those tags, so
urban areas generate as uniform flat boxes.

This adds an optional `--catastro` mode (and a GUI toggle) that fetches
the real number of floors per building from the Spanish Cadastre's free
INSPIRE Buildings WFS for the generation area, matches each Cadastre
BuildingPart to the OSM building it overlaps most, and injects a
`building:levels` tag before parsing — so the existing height, roof and
window logic applies unchanged.

Spain only (excludes the Basque Country and Navarra, which run their own
cadastre). Degrades gracefully: outside Spain, or on a service failure,
the world is generated with the usual defaults.

- New module src/catastro.rs: WFS fetch (tile grid + quadtree fallback),
  GML parsing via roxmltree, footprint matching via the geo crate
- CLI flag --catastro and GUI checkbox "Real heights (Spain / Catastro)"
- New dependency: roxmltree

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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