cartagen.regularize_building_regression

cartagen.regularize_building_regression#

regularize_building_regression(polygon, sigma)#

Regularize a polygon using recursive linear regression.

This algorithm was proposed by Bayer [1] and used for remote sensing building regularization in Yang. [2] It first defines the four sides of the polygon using an enclosing rectangle that has one side touching the side of the polygon. Then, every side is recursively subdivided until the standard deviation of the vertex composing the side is below the provided threshold. The standard deviation is calculated using the horizontal or vertical regression line which will output a squared polygon.

Parameters:
  • polygon (Polygon) – The polygon to regularize.

  • sigma (float) – The standard deviation threshold above which the recursion continues.

Returns:

Polygon

See also

enclosing_rectangle

Construct an enclosing rectangle from a polygon.

regularize_building_rectangle

Transform a polygon into a rectangle.

regularize_building_fer

Regularize a polygon using feature edge reconstruction.

Notes

This algorithm always squares the provided polygon, this can create strange results when using on polygons that are not supposed to be square.

References

Examples

>>> polygon = Polygon([(0, 0), (0, 2), (1, 2), (1, 1), (2, 1), (2, 0), (0, 0)])
>>> regularize_building_regression(polygon, 1.0)
<POLYGON ((0 0, 0 2, 1.5 2, 1.5 0, 0 0))>

(Source code)

../_images/regularize_building_regression.png