mask_to_building_polygons#
- mask_to_building_polygons(mask: ndarray, transform: affine.Affine | None = None, min_area: float = 100, width_factor: float = 0.5, thickness: float = 0.001) Iterator[BaseGeometry][source]#
Try to break up building clusters and then convert to polygons.
Perofrms the following steps:
Identify connected components in
mask.For each connected component, if >=
min_area:Generate a kernel based on its dimensions and orientation and the
width_factorandthicknessparams.Use the kernel to apply morphological erosion to component- mask.
Identify connected sub-components in component-mask.
For each connected sub-component, if >=
min_area:Apply morphological dilation using the kernel from above.
Polygonize using
mask_to_polygons().
- Parameters:
mask (np.ndarray) – The mask containing buildings to polygonize.
transform (rio.Affine|None) – Affine transform to use during polygonization. Defaults to None (i.e. identity transform).
min_area (float) – Minimum area (in pixels^2) of anything that can be considered to be a building or cluster of buildings. The goal is to distinguish between buildings and artifacts. Components with area less than this value will be discarded. Defaults to 100.
width_factor (float) – Width of the structural element used to break building clusters as a fraction of the width of the cluster.
thickness (float) – Thickness of the structural element that is used to break building clusters. Defaults to 0.001.
- Returns:
Generator of shapely polygons.
- Return type:
Iterator[BaseGeometry]