Compute Index
SpectralIndices.compute_index
— Functioncompute_index(index::String, params::Dict=Dict(), online::Bool=false; kwargs...) -> Any
Computes one or more Spectral Indices from a predefined list, based on the provided index name, parameters, and optional keyword arguments.
Parameters
index
: Name of the spectral index or a list of index names to compute.params
: (Optional) Dictionary of parameters used as inputs for the computation. If not provided, parameters can be passed using keyword arguments.online
: (Optional) Flag indicating whether to retrieve the most recent list of indices online.kwargs
: Additional parameters used as inputs for the computation, provided as keyword pairs.
Returns
- Computed Spectral Indices, the type of return value depends on the input parameters.
Examples
julia> compute_index("NDVI"; N=0.643, R=0.175)
julia> compute_index("NDVI"; N=fill(0.643, (5, 5)), R=fill(0.175, (5, 5)))
julia> compute_index("NDVI"; N=fill(0.643, 5), R=fill(0.175, 5))
julia> compute_index(["NDVI", "SAVI"]; N=fill(0.643, 5), R=fill(0.175, 5), L=fill(0.5, 5))
julia> compute_index(["NDVI", "SAVI"]; N=0.643, R=0.175, L=0.5)
julia> compute_index(
["NDVI", "SAVI"]; N=fill(0.643, (5, 5)), R=fill(0.175, (5, 5)), L=fill(0.5, (5, 5))
)
SpectralIndices.compute_kernel
— Functioncompute_kernel(kernel, params=nothing; kwargs...)
Compute a specified kernel using either provided parameters or keyword arguments.
Arguments
kernel
: The kernel function to use. Should be one oflinear
,poly
, orRBF
.params
: (Optional) ADict
,DataFrame
, orYAXArray
containing parameters for the kernel computation.kwargs...
: Keyword arguments that will be converted to parameters ifparams
is not provided.
Returns
- The result of the kernel computation, the type of which depends on the input type.
Examples
result = compute_kernel(linear; params=Dict("a" => 1, "b" => 2))
SpectralIndices.linear
— Functionlinear(a::Number, b::Number)
linear(a::AbstractArray, b::AbstractArray)
linear(params::Dict{String, T})
linear(params::DataFrame)
linear(params::YAXArray)
Compute the linear kernel a * b
. This function supports various input types, including numbers, arrays, dictionaries, data frames, and YAXArrays.
Arguments
a
: First parameter for the linear kernel. Can be a number or an array.b
: Second parameter for the linear kernel. Can be a number or an array.params
: A dictionary, data frame, or YAXArray containing the parameters "a" and "b".
Returns
The result of
a * b
. The output type depends on the input types:- If
a
andb
are numbers, the result is a number. - If
a
andb
are arrays, the result is an array with element-wise multiplication. - If
params
is used, the result is in the same format asparams
(either a dictionary, DataFrame, or YAXArray).
- If
Examples
# Using numbers
result = linear(2, 3)
# Using arrays
result = linear([1, 2, 3], [4, 5, 6])
# Using a dictionary
result = linear(Dict("a" => 2, "b" => 3))
# Using a DataFrame
df = DataFrame(; a=[1, 2, 3], b=[4, 5, 6])
result = linear(df)
SpectralIndices.poly
— Functionpoly(a::T, b::T, c::T, p::T) where T <: Number
poly(a::T, b::T, c::T, p::T) where T <: AbstractArray
poly(params::Dict{String, T})
poly(params::DataFrame)
poly(params::YAXArray)
Compute the polynomial kernel (a * b + c) ^ p
. This function supports various input types, including numbers, arrays, dictionaries, data frames, and YAXArrays.
Arguments
a
: First parameter for the polynomial kernel. Can be a number or an array.b
: Second parameter for the polynomial kernel. Can be a number or an array.c
: Coefficient added to the product ofa
andb
. Can be a number or an array.p
: Exponent to which the sum of the product and coefficient is raised. Can be a number or an array.params
: A dictionary, data frame, or YAXArray containing the parameters "a", "b", "c", and "p".
Returns
The result of
(a * b + c) ^ p
. The output type depends on the input types:- If
a
,b
,c
, andp
are numbers, the result is a number. - If
a
,b
,c
, andp
are arrays, the result is an array with the operation applied element-wise. - If
params
is used, the result matches the format ofparams
(either a dictionary, DataFrame, or YAXArray).
- If
Examples
# Using numbers
result = poly(2, 3, 1, 2)
# Using arrays
result = poly([1, 2, 3], [4, 5, 6], [1, 1, 1], [2, 2, 2])
# Using a dictionary
result = poly(Dict("a" => 2, "b" => 3, "c" => 1, "p" => 2))
# Using a DataFrame
df = DataFrame(; a=[1, 2, 3], b=[4, 5, 6], c=[1, 1, 1], p=[2, 2, 2])
result = poly(df)
SpectralIndices.RBF
— FunctionRBF(a::T, b::T, sigma::T) where T <: Number
RBF(a::T, b::T, sigma::T) where T <: AbstractArray
RBF(params::Dict{String, T})
RBF(params::DataFrame)
RBF(params::YAXArray)
Compute the Radial Basis Function (RBF) kernel exp((-1.0 * (a - b) ^ 2.0) / (2.0 * sigma ^ 2.0))
. This function supports various input types, including numbers, arrays, dictionaries, data frames, and YAXArrays.
Arguments
a
: First parameter for the RBF kernel. Can be a number or an array.b
: Second parameter for the RBF kernel. Can be a number or an array.sigma
: Length-scale parameter for the RBF kernel. Can be a number or an array.params
: A dictionary, data frame, or YAXArray containing the parameters "a", "b", and "sigma".
Returns
The result of the RBF kernel. The output type depends on the input types:
- If
a
,b
, andsigma
are numbers, the result is a number. - If
a
,b
, andsigma
are arrays, the result is an array with the operation applied element-wise. - If
params
is used, the result matches the format ofparams
(either a dictionary, DataFrame, or YAXArray).
- If
Examples
# Using numbers
result = RBF(1, 2, 0.5)
# Using arrays
result = RBF([1, 2, 3], [4, 5, 6], [0.5, 0.5, 0.5])
# Using a dictionary
result = RBF(Dict("a" => 1, "b" => 2, "sigma" => 0.5))
# Using a DataFrame
df = DataFrame(; a=[1, 2, 3], b=[4, 5, 6], sigma=[0.5, 0.5, 0.5])
result = RBF(df)