cartagen.simplify_building_morphological#
- simplify_building_morphological(building, tolerance, max_iteration=100)#
Simplify buildings using morphological closing and structural generalization.
This algorithm performs a global structural simplification. For MultiPolygon, it uses a morphological closing (buffer expansion and contraction using mitre joins) to merge nearby structures and clear micro-gaps. For individual rings (exterior and interior), it iteratively detects and processes small segments below the threshold, relocating vertices to force parallel extensions or orthogonal alignments.
This algorithm is a Python translation of the Lithuanian openmap association vector-map repository simplification algorithm.
- Parameters:
building (
PolygonorMultiPolygon) – The shapely geometry (building) to be simplified.tolerance (
float) – The maximum distance tolerance for geometric simplification. Also used as the buffer distance for morphological closing and as a square root threshold (tolerance^2) for filtering out small interior rings.max_iteration (
int, optional) – The maximum number of iterative vertex adjustments allowed during the line simplification phase. The default value is set to 100.
- Returns:
PolygonorMultiPolygon– The simplified building geometry of the same type as the input.
See also
simplify_building_ruasSimplify buildings by removing edges using Ruas algorithm.
Examples
>>> from shapely.geometry import Polygon >>> building = Polygon([(0, 0), (0, 10), (2, 10), (2, 9), (10, 9), (10, 0), (0, 0)]) >>> simplify_building_morphological(building, 2.0) <POLYGON ((0 0, 0 9, 10 9, 10 0, 0 0))>