|
22 | 22 | #' @param raster The raster (either as a SpatRaster or object readable by
|
23 | 23 | #' [terra::rast()]) to compute indices from.
|
24 | 24 | #' @param indices A data frame of indices to compute. The intent is for this
|
25 |
| -#' function to work with subsets of [spectral_indices], but any data frame with |
26 |
| -#' columns `formula` (containing a string representation of the equation used |
27 |
| -#' to calculate the index), `bands` (a list column containing character vectors |
28 |
| -#' of the necessary bands) and `short_name` (which will be used as the band |
29 |
| -#' name) will work. |
| 25 | +#' function to work with subsets of [spectral_indices()], but you can provide |
| 26 | +#' any data frame with `formula`, `bands`, and `short_name` columns; see |
| 27 | +#' "Custom indices" below. |
30 | 28 | #' @param output_filename The filename to write the computed metrics to.
|
31 | 29 | #' @inheritParams rlang::args_dots_empty
|
32 | 30 | #' @inheritParams terra::predict
|
|
40 | 38 | #' @param names_suffix If not `NULL`, will be used (with [paste()]) to add a
|
41 | 39 | #' suffix to each of the band names returned.
|
42 | 40 | #'
|
| 41 | +#' @section Custom indices: |
| 42 | +#' While this function is designed to work with subsets of [spectral_indices()], |
| 43 | +#' you can also provide your own custom indices by providing a data frame with |
| 44 | +#' at least three columns: |
| 45 | +#' |
| 46 | +#' * `formula` should contain a string representation of the equation used to |
| 47 | +#' calculate the index. This string will be interpreted as R code, and should use |
| 48 | +#' normal R arithmetic operators. Any additional functions used in calculating the |
| 49 | +#' index will need to be passed through `extra_objects`. |
| 50 | +#' * `bands` should be a list column containing character vectors identifying the |
| 51 | +#' bands required to calculate the index. These vectors will be checked against the |
| 52 | +#' band names of `raster` to make sure that all necessary bands are available |
| 53 | +#' before indices are calculated. |
| 54 | +#' * `short_name` should contain a string which will be used as the band name in |
| 55 | +#' the final output file. |
| 56 | +#' |
| 57 | +#' Sometimes you might want to tweak the formula used for an existing index, for |
| 58 | +#' instance to set non-data parameters to constant values. In that case, make sure |
| 59 | +#' you also update `bands` to reflect just the bands required by your updated formula, |
| 60 | +#' so that the function won't error unnecessarily. |
| 61 | +#' |
43 | 62 | #' @return `output_filename`, unchanged.
|
44 | 63 | #'
|
45 | 64 | #' @examples
|
|
0 commit comments