Skip to content

awesome-spectral-indices/SpectralIndices.jl

Repository files navigation

SpectralIndices.jl

Documentation Build Status Julia Testing
docs CI codecov Julia Code Style: Blue Aqua QA

Overview 📖

SpectralIndices.jl is a Julia package for working with spectral indices commonly used in remote sensing and earth observation applications. It provides a convenient way to compute various spectral indices using Julia's high-performance capabilities.

Features 🚀

  • Computation for a wide range of spectral indices
  • Computation support for Float64, Float32 and Float16 at index formula level to support fast computation for ML applications
  • Support for various data types, including but not limited to (see this issue for an updated list and WIP)
    • Arrays
    • DataFrames
    • YAXArrays
  • Flexible parameter input options
  • Compatibility with multiple remote sensing platforms and sensors

Installation 💻

SpectralIndices.jl is registered in the general registry, please install it using the following:

julia> ]
pkg> add SpectralIndices

or

using Pkg
Pkg.add("SpectralIndices")

Usage 🛠️

You can compute spectral indices either by specifying the index and its parameters or using predefined SpectralIndex instances.

Using compute_index

using SpectralIndices
using DataFrames

# Compute NDVI with direct parameter input
result = compute_index("NDVI", N = 0.643, R = 0.175)

# Compute NDVI with direct parameter input and direct NDVI call
result = compute_index(NDVI, N = 0.643, R = 0.175)

# Compute multiple indices with array inputs
multi_result = compute_index(["NDVI", "SAVI"], N = fill(0.643, 5), R = fill(0.175, 5), L = fill(0.5, 5))

# use Dataframes
df = DataFrame(N = [0.643, 0.560], R = [0.175, 0.225])
result_df_single = compute_index("NDVI", df)
# Multiple inputs in a dataframe
df = DataFrame(N = [0.643, 0.560], R = [0.175, 0.225], L = [0.5, 0.5])
result_df_multiple = compute_index(["NDVI", "SAVI"], df)

To compute at custom Float precision input the bands at the chosen precision and specify the Float type to the compute_index function

# Compute NDVI with direct parameter input
result = compute_index(Float32, "NDVI", N = Float32(0.643), R = Float32(0.175))

Using compute

# Define a SpectralIndex instance

# Compute using the instance with keyword arguments
result = compute(NDVI, N = 0.643, R = 0.175) #NDVI is autmatically in namespace with the import of SpectraIndices.jl

# Compute with array inputs
array_result = compute(NDVI, N = fill(0.643, (5, 5)), R = fill(0.175, (5, 5)))

For more advanced usage and detailed documentation, please refer to the documentation.

Code Structure

fig1

Contributing 🤝

Contributions to SpectralIndices.jl are welcome! If you would like to contribute, please see our Contribution Guidelines for more information.

License 📜

SpectralIndices.jl is licensed under the MIT License. See LICENSE for more information.

Acknowledgments ✨

This package is inspired by the Spyndex Python library for spectral indices. The logo is AI-generated by dalle3 through ChatGPT and modified by the talented David Montero.

Support 🆘

If you have any questions, issues, or feature requests, please open an issue or contact us via email.

Citation 🔗

If you use SpectralIndices.jl in your research, please consider citing it using the following DOI:

@article{montero2023standardized,
  title={A standardized catalogue of spectral indices to advance the use of remote sensing in Earth system research},
  author={Montero, David and Aybar, C{\'e}sar and Mahecha, Miguel D and Martinuzzi, Francesco and S{\"o}chting, Maximilian and Wieneke, Sebastian},
  journal={Scientific Data},
  volume={10},
  number={1},
  pages={197},
  year={2023},
  publisher={Nature Publishing Group UK London}
}

RSC4Earth