Spatial smoothing methods for probability maps.
Project description
smoother.py 🧹
Spatial smoothing methods for probability maps.
Installation
To install the package, you can use pip:
pip install git+https://github.com/m3nin0-labs/smoother.py
Methods available
Currently, the smoother implements the Bayes smoothing method, adapting the code from the sits R package.
Usage
First, import the package:
import smoother
Then, use the smooth function on the numpy data of your map. The smoothing method is selected with method (defaults to "bayes"), and any method-specific options are passed as keyword arguments:
smoothed = smoother.smooth(your_numpy_array)
# selecting the method explicitly and tuning it
smoothed = smoother.smooth(your_numpy_array, method="bayes", window_size=5)
You can use rasterio or other library to load the numpy array.
xarray
smooth also accepts xarray objects. To use it, first install the xarray dependencies:
pip install "smoother-py[xarray]"
Then, using your xarray data, you can call the smooth function:
# DataArray with class, y and x dimensions
smoothed = smoother.smooth(your_data_array)
# dimension names are inferred (e.g. band/class, y/latitude, x/longitude)
# you can also name them explicitly
smoothed = smoother.smooth(your_data_array, class_dim="band")
Extra dimensions (e.g. time) are smoothed per layer automatically.
Discovering the options
smoother.smooth documents every option, the smoothing parameters and the xarray-only dimension names:
help(smoother.smooth)
Development
The project uses uv to manage the development environment:
# create the environment and build/install the package
uv sync
# run the tests
uv run pytest
Learn more
The smoothing methods implemented in this package uses the approach described in the sits documentation. This method helps in refining the probability maps by considering the spatial context of each pixel.
Acknowledgments
We would like to thank the developers and contributors of the sits R package for their work on spatial smoothing methods for Earth observation data. Their comprehensive documentation and methodologies have been invaluable in the development of smoother.py.
Contributing
We welcome contributions! If you have suggestions for improvements or bug fixes, please feel free to fork the repository and submit a pull request.
License
smoother.py is distributed under the MIT license. See LICENSE for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smoother_py-0.1.0.tar.gz.
File metadata
- Download URL: smoother_py-0.1.0.tar.gz
- Upload date:
- Size: 345.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4e4e7f3faf4af8afd3aa9fcff783a6295325df04333c54abe46869016d9ca7c
|
|
| MD5 |
ca86a0d4830e2dc0bc0ebf0f6dd9ac39
|
|
| BLAKE2b-256 |
41a986ebc6d924aad6aefcbcd773ef8c098b10b94b056deabc5ed81a2e3b975e
|
File details
Details for the file smoother_py-0.1.0-cp312-abi3-macosx_26_0_arm64.whl.
File metadata
- Download URL: smoother_py-0.1.0-cp312-abi3-macosx_26_0_arm64.whl
- Upload date:
- Size: 51.9 kB
- Tags: CPython 3.12+, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fa6c4d6505d206edadfb40f820e30fbda6e17e922cbf310396904db7030dcd5
|
|
| MD5 |
970f11b76cda62ecff0b763087e649da
|
|
| BLAKE2b-256 |
7f15b2fcabc7e25f6ce606e8e55d810b9997aca3354782ad537046b0dc5d405e
|