Skip to main content

Spatial raster prediction with scikit-learn estimators.

Project description

sklearn-raster

PyPI version Build status Documentation status

⚠️ WARNING: sklearn-raster is in active development! ⚠️

sklearn-raster extends scikit-learn and other compatible estimators to work directly with raster data. This allows you to train models with tabular data and predict raster outputs directly while preserving metadata like spatial references, band names, and NoData masks.

Features

  • ⚡ Parallelized functions + larger-than-memory data using Dask
  • 🌐 Automatic handling of spatial references, band names, and masks
  • 🔢 Support for n-dimensional feature arrays, e.g. time series rasters

Quick-Start

  1. Install optional dependencies for loading data and plotting results:

    pip install "sklearn-raster[tutorials]"
    
  2. Wrap a scikit-learn estimator with a FeatureArrayEstimator to enable raster-based predictions:

    from sklearn.ensemble import RandomForestRegressor
    from sklearn_raster import FeatureArrayEstimator
    
    est = FeatureArrayEstimator(RandomForestRegressor())
    
  3. Load a custom dataset of features and targets and fit the wrapped estimator:

    from sklearn_raster.datasets import load_swo_ecoplot
    
    X_image, X, y = load_swo_ecoplot(as_dataset=True)
    est.fit(X, y)
    
  4. Generate predictions from a numpy or xarray raster with predictors as bands:

    pred = est.predict(X_image)
    pred["PSME_COV"].plot()
    

Acknowledgements

Thanks to the USDA Forest Service Region 6 Ecology Team for the inclusion of the SWO Ecoplot dataset (Atzet et al., 1996). Development of this package was funded by:

  • an appointment to the United States Forest Service (USFS) Research Participation Program administered by the Oak Ridge Institute for Science and Education (ORISE) through an interagency agreement between the U.S. Department of Energy (DOE) and the U.S. Department of Agriculture (USDA).
  • a joint venture agreement between USFS Pacific Northwest Research Station and Oregon State University (agreement 19-JV-11261959-064).
  • a cost-reimbursable agreement between USFS Region 6 and Oregon State University (agreeement 21-CR-11062756-046).

References

  • Atzet, T, DE White, LA McCrimmon, PA Martinez, PR Fong, and VD Randall. 1996. Field guide to the forested plant associations of southwestern Oregon. USDA Forest Service. Pacific Northwest Region, Technical Paper R6-NR-ECOL-TP-17-96.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sklearn_raster-0.1.0.dev1.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sklearn_raster-0.1.0.dev1-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

Details for the file sklearn_raster-0.1.0.dev1.tar.gz.

File metadata

  • Download URL: sklearn_raster-0.1.0.dev1.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sklearn_raster-0.1.0.dev1.tar.gz
Algorithm Hash digest
SHA256 9dba7bcd3d9362d08fd39b0223f70fa9df2bcc54c6c17fb618b932ae9450dd61
MD5 49f9caa54aa944e3a5995c9fc58b1a26
BLAKE2b-256 b6be458ded4688eca2d10de41c1c25d48967972ab5c61f6af1a9e5caa07f616d

See more details on using hashes here.

Provenance

The following attestation bundles were made for sklearn_raster-0.1.0.dev1.tar.gz:

Publisher: publish.yaml on lemma-osu/sklearn-raster

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sklearn_raster-0.1.0.dev1-py3-none-any.whl.

File metadata

File hashes

Hashes for sklearn_raster-0.1.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 32b056c30f7344a4fecb183a7e9380d92382a966d1093101af702a6991deb4b4
MD5 625b840c3ef99b7a0f36e89226788211
BLAKE2b-256 2ec3fbaa4ab12dc9d004685fded3fc056e0e17c3aedd7f4ba1992b7ebb75eed1

See more details on using hashes here.

Provenance

The following attestation bundles were made for sklearn_raster-0.1.0.dev1-py3-none-any.whl:

Publisher: publish.yaml on lemma-osu/sklearn-raster

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page