- 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] #
Try to break up building clusters and then convert to polygons.
Perofrms the following steps:
Identify connected components in
For each connected component, if >=
Generate a kernel based on its dimensions and orientation and the
Use the kernel to apply morphological erosion to component- mask.
Identify connected sub-components in component-mask.
For each connected sub-component, if >=
Apply morphological dilation using the kernel from above.
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