geodata.mask.filter_area#
- geodata.mask.filter_area(self, min_area: float, layer_name: str | None = None, dest_layer_name: str | None = None, shape_value: int = 1, src_crs: str = 'EPSG:4326', area_calc_crs: str = 'EPSG:6933', connectivity: Literal[4, 8] = 4) rasterio.DatasetReader#
Eliminate the small area of a certain value in the raster by converting it to an equal-area reprojected series of connected shapes, removing shapes that are smaller than the given area in km^2, and turning it back to a raster.
- Parameters:
min_area (float) – The area threshold in km^2. Any connected group with smaller area then this parameter will be removed from the raster.
layer_name (str) – The name of the raster to be selected from the mask object If not specified, the method will use the merged_mask layer
dest_layer_name (str) – The name of the new raster to be formed from eliminating small area in the original layer. If not specified, this function will return the raster instead of assigning it to the layers.
shape_value (int) – The value of the grid cells to be groups for elimination. 1 by default. (Find all the connected groups of cells with area 1)
src_crs (str) – The CRS of the raster to be selected from the mask object. EPSG:4326 by default.
area_calc_crs (str) – The CRS used for reprojecting the raster for area calculation. EPSG:6933 by default. (Equal area projection)
connectivity (int) – Should either be 4 or 8. If 4, then the 4 surrounding cells of each grid cell will be counted for grouping connected grid cells, otherwise, all 8 surround cells of each grid cell will be counted.
- Returns:
The raster with small area eliminated.
- Return type:
ras.DatasetReader
- Raises:
KeyError – If the layer_name does not exist in the mask object.