cartagen.regularize_building_fer#
- regularize_building_fer(polygon, length=6.0, area=6.0)#
Regularize a polygon using feature edge reconstruction.
This algorithm was proposed by Yang et al. [1]. FER enforces orthogonality and clean edge alignment on raw segmentation polygons. It first estimates the dominant orientation of a building, then iteratively snaps near-parallel and near-perpendicular edges to that principal axis, using Douglas-Peucker simplification, minimum-rotated-rectangle fitting, and a local reconstruction loop.
This is slightly modified version of the SamGeo Python package available here. It is basically the same but without the osgeo dependencies.
- Parameters:
polygon (
PolygonorMultiPolygon) – Input building footprint(s) to regularize.length (
float) – Minimum edge length used during the reconstruction pass (default 6 m).area (
float) – Polygons whose area is below this value (m²) are discarded (default 6 m²).
- Returns:
PolygonorMultiPolygonorNone– The regularised geometry, preserving the input type. Returns None if the geometry is entirely filtered out.
See also
enclosing_rectangleConstruct an enclosing rectangle from a polygon.
regularize_building_rectangleTransform a polygon into a rectangle.
regularize_building_regressionRegularize a polygon using recursive linear regression.
Notes
FER preserves overall shape well and handles irregular, non-axis-aligned buildings. But it assumes roughly rectilinear architecture and tuning length and area may be needed for dense urban scenes or very small footprints.
References
Examples
>>> polygon = Polygon([(0, 0), (0, 2), (1, 2), (1, 1), (2, 1), (2, 0), (0, 0)]) >>> regularize_building_fer(polygon, 1.0, 1.0) <POLYGON ((0 0, 0 2, 1.5 2, 1.5 0, 0 0))>