A Python CLI tool suite, made for the MultiRoofs project, for processing CityJSON files.
The roofarea command processes CityJSON files containing Buildings (and BuildingParts) and adds a total_area_roof attribute to each CityObject. The value is calculated as the sum of areas of all surfaces semantically labeled as "RoofSurface".
If a building has no semantic information, total_area_roof is set to 0.0.
Install the package in development mode:
uv pip install -e .Basic usage:
uv run mrtools roofarea input.city.json -o output.city.jsonVerbose mode (shows processing details):
uv run mrtools roofarea input.city.json -o output.city.json --verboseProcessing: data/3dbag_b2.city.json
✓ Processed 4 CityObjects
NL.IMBAG.Pand.0503100000028341-0 (BuildingPart): 186.71 m²
NL.IMBAG.Pand.0503100000028341 (Building): 0.00 m²
NL.IMBAG.Pand.0503100000031927-0 (BuildingPart): 233.79 m²
... and 1 more objects
✓ Output written to: data/3dbag_b2_output.city.json
The tool handles both geometry types found in CityJSON:
- Solid geometry (e.g., Dutch 3DBAG):
boundaries[shell][face][ring][vertex] - MultiSurface geometry (e.g., Montréal dataset):
boundaries[face][ring][vertex]
mrtools/
├── src/
│ └── mrtools/
│ ├── __init__.py # Package initialization
│ ├── cli.py # Typer CLI interface with subcommands
│ ├── processor.py # CityJSON processing logic
│ └── geometry.py # Geometric calculations
├── data/ # Sample CityJSON files
│ ├── 3dbag_b2.city.json
│ └── montréal_b4.city.json
├── tests/ # Test files
├── pyproject.toml # Project configuration
└── README.md
uv run pytest
pip install typer pytest
- Python >= 3.13
- typer >= 0.12.0
- pytest >= 9.0.2