sieve#
- sieve(xds: str | CloudPath | Path | tuple[ndarray | MaskedArray, dict] | DataArray | Dataset | DatasetReader | DatasetWriter, sieve_thresh: int, connectivity: int = 4) DataArray | Dataset [source]#
Sieving, overloads rasterio function with raster shaped like an image:
(1, h, w)
.Warning
Your data is casted by force into
np.uint8
, so be sure that your data is classified.- Parameters:
- Returns:
Sieved xarray
- Return type:
(AnyXrDataStructure)
Example
>>> raster_path = "path/to/raster.tif" # classified raster >>> >>> # Rewrite it >>> sieved_xds = sieve(raster_path, sieve_thresh=20) >>> >>> # Write it >>> raster_out = "path/to/raster_sieved.tif" >>> write(sieved_xds, raster_out)