mask_to_building_polygons(mask: ndarray, transform: Optional[Affine] = 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:

  1. Identify connected components in mask.

  2. For each connected component, if >= min_area:

    1. Generate a kernel based on its dimensions and orientation and the width_factor and thickness params.

    2. Use the kernel to apply morphological erosion to component- mask.

    3. Identify connected sub-components in component-mask.

    4. For each connected sub-component, if >= min_area:

      1. Apply morphological dilation using the kernel from above.

      2. Polygonize using mask_to_polygons().

  • mask (np.ndarray) – The mask containing buildings to polygonize.

  • transform (Optional[rio.Affine]) – Affine transform to use during polygonization. Deafults 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.


Generator of shapely polygons.

Return type