Skip to main content

Download and load soil spectral data

Project description

SoilSpecData

A Python package for handling soil spectroscopy data, with a focus on the Open Soil Spectral Library (OSSL).

Installation

pip install soilspecdata

Features

  • Easy loading and handling of OSSL dataset
  • Support for both VISNIR (Visible Near-Infrared) and MIR (Mid-Infrared) spectral data
  • Flexible wavelength range filtering
  • Convenient access to soil properties and metadata
  • Automatic caching of downloaded data
  • Get aligned spectra and target variable(s)
  • Further datasets to come …

Quick Start

# Import the package
from soilspecdata.datasets.ossl import get_ossl

Load the OSSL dataset:

ossl = get_ossl()
  • Get MIR spectra (600-4000 cm⁻¹):
mir_data = ossl.get_mir(require_valid=True)
  • Get VISNIR spectra with custom wavelength range:
visnir_data = ossl.get_visnir(wmin=500, wmax=1000, require_valid=True)
  • Get soil properties (e.g., CEC):
properties = ossl.get_properties(['cec_usda.a723_cmolc.kg'], require_complete=True)

For more details on the OSSL dataset and its variables, see the OSSL documentation.

  • Get metadata (e.g., geographical coordinates):
metadata = ossl.get_properties(['longitude.point_wgs84_dd', 'latitude.point_wgs84_dd'], require_complete=False)
  • Or to get directly aligned spectra and target variable(s):
X, y, ids = ossl.get_aligned_data(
    spectra_data=mir_data,
    target_cols='cec_usda.a723_cmolc.kg'
)

X.shape, y.shape, ids.shape
((57062, 1701), (57062, 1), (57062,))

Data Structure

The package returns spectra data in a structured format containing: - Wavenumbers - Spectra measurements - Measurement type (reflectance/absorbance) - Sample IDs

Properties and metadata are returned as pandas DataFrames indexed by sample ID.

Cache Management

By default, the OSSL dataset is cached in ~/.soilspecdata/. To force a fresh download:

ossl = get_ossl(force_download=True)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

Apache2

Citation

TBC

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

soilspecdata-0.0.2.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

soilspecdata-0.0.2-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file soilspecdata-0.0.2.tar.gz.

File metadata

  • Download URL: soilspecdata-0.0.2.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.16

File hashes

Hashes for soilspecdata-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1b672909ffa7699f7a2d586734e1acaa9fa296df0797a074619cd9db7a12f788
MD5 6293b996c1167900fc791f140bd4f958
BLAKE2b-256 53954a223a768fb20fab642eda9fa8e7bac19c4635683eebc69921ea266c64a5

See more details on using hashes here.

File details

Details for the file soilspecdata-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: soilspecdata-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.16

File hashes

Hashes for soilspecdata-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 160b303985f9ed2ef198a9a0acc8a514cc0e0a1231d46b05fd9e60f93550c967
MD5 f70a6367d0f647d79b0092e38af1bf9e
BLAKE2b-256 5a6a66d035676fbb21d166939d495e1e040d1cd01acc35554a03e2e853f4b261

See more details on using hashes here.

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