diff --git a/DESCRIPTION b/DESCRIPTION index ca1adbbc05426fe08e3e2b7f79dc8c29c953f258..1044ce6bffd6fc780584813a5525dabed71efd46 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: lidaRtRee Type: Package Version: 4.0.7 Title: Forest Analysis with Airborne Laser Scanning (LiDAR) Data -Date: 2024-03-13 +Date: 2024-09-13 Authors@R: c( person("Jean-Matthieu", "Monnet", email = "jean-matthieu.monnet@inrae.fr", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-9948-9891")), person("Pascal", "Obstétar", email = "pascal.obstetar@onf.fr", role = c("ctb"), comment = c(ORCID = "0000-0002-2811-7548"))) @@ -24,5 +24,5 @@ Imports: graphics, stats, methods, grDevices, terra, sf, imager, leaps, gvlma, c Suggests: stars License: GPL-3 LazyData: TRUE -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Encoding: UTF-8 diff --git a/NEWS.md b/NEWS.md index 3c40bdec4556da10c28356f655fe2e46a4818481..3aac860caa588058a36bf2075d5ac92886137e57 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,11 +3,14 @@ ## New * `clouds_tree_metrics()` now has a `roi` argument to select trees to retain for subsequent computation based on spatial object. +* `ABA_predict()` now has a `...` argument to pass additional arguments to `stats::predict.lm()`. ## Change * `boxcox_tr()` and `boxcox_itr()` do not automatically replace `0` with `NA` anymore. * `RasterLayer` objects are not supported anymore as the `raster` package package is now obsolete. +* in `aba_build_model()`, when specified the minimum `threshold` parameter now replaces non finite values in predictions. +* added `...` argument in `aba_build_model()`: passed to `leaps::regsubsets()` # lidaRtRee 4.0.6 diff --git a/R/aba.R b/R/aba.R index 435d1da2c7b068548ca13d1d152e339122ed6fed..9dd6f998b9b829a405ef19de9642c5d840d5cfa8 100755 --- a/R/aba.R +++ b/R/aba.R @@ -38,7 +38,10 @@ #' observations: not used in the function but exported in the result for use in #' further inference functions #' @param threshold vector of length two. minimum and maximum values of threshold -#' to apply to predicted values +#' to apply to predicted values. Non-finite values are replaced by the minimum. +#' Values are replaced after computation of the variance of residuals used for +#' bias correction +#' @param ... other parameters to be passed to \code{\link[leaps]{regsubsets}}, #' #' @seealso \code{\link{aba_combine_strata}} for combining models calibrated #' on different strata, \code{\link{aba_plot}} for plotting model @@ -84,7 +87,8 @@ aba_build_model <- nmax = 3, test = c("partial_p", "vif", "gvlma"), xy = NULL, - threshold = NULL) { + threshold = NULL, + ...) { # build data.frame with dependent variable and predictors df <- data.frame(dep_var = variable, predictors) row.names(df) <- row.names(predictors) @@ -147,7 +151,8 @@ aba_build_model <- nbest = 20, nvmax = nmax - 1, method = "exhaustive", - really.big = TRUE + really.big = TRUE, + ... ) ) #----------------------------------------------------------------------------- @@ -229,6 +234,7 @@ aba_build_model <- if (!is.null(threshold)) { prediction <- pmin(prediction, threshold[2]) prediction <- pmax(prediction, threshold[1]) + prediction[!is.finite(prediction)] <- threshold[1] } # #--------------------------------------------------------------------------- @@ -697,6 +703,7 @@ aba_plot <- #' \code{log} transformation case #' @param pkg raster output format. Use pkg = "terra|raster|stars" to get an output in SpatRaster, RasterLayer #' or stars format. +#' @param ... other parameters to be passed to \code{\link[stats]{predict.lm}}, e.g. \code{interval = "prediction"}, #' @examples #' # load data #' data(quatre_montagnes) @@ -724,7 +731,8 @@ aba_predict <- metrics_map, stratum = NULL, add_error = FALSE, - pkg = "terra") { + pkg = "terra", + ...) { # convert to terra if(!inherits(metrics_map, "SpatRaster")) metrics_map <- convert_raster(metrics_map, "terra") # create factor of stratum if not existing @@ -757,7 +765,8 @@ aba_predict <- } # predict on all cells r[[stratum_label]] <- terra::predict(newdata, - model_aba$model[[stratum_label]]) + model_aba$model[[stratum_label]], + ...) if (model_aba$stats[stratum_label, "transform"] == "boxcox") # case of Box-Cox transform diff --git a/R/optical_metrics.R b/R/optical_metrics.R index ec32722a0cd01494fb37857587030c42ad58738b..d704e59d4728a16cffb46b053931be3ecb25e67f 100755 --- a/R/optical_metrics.R +++ b/R/optical_metrics.R @@ -7,7 +7,7 @@ #' #' Computes vegetation indices from the Red, Green and Infra-Red bands of an IRC #' image and adds them as additional bands or columns. Acronyms are listed on -#' \url{https://www.l3harrisgeospatial.com/docs/broadbandgreenness.html}. If the +#' \url{https://www.nv5geospatialsoftware.com/docs/BroadbandGreenness.html}. If the #' Blue band is also present, additional indices are computed. #' #' @param r raster or data.frame. Should contain bands or columns with diff --git a/README.md b/README.md index 9e6d2ceeeed8d3aa6dac8c4c6bcc5d08523cebd8..37f14f672e1d0f412a5835406b7068afcc30fc1d 100755 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ Tutorials using `lidaRtRee` functions are available in the [vignettes](https://f # Acknowledgements / funding -`lidaRtRee` development (2018-2021) was funded by the [ADEME](https://www.ademe.fr/en) (french Agency for Ecological Transition) through the [PROTEST](https://protest.inrae.fr/) project (grant 1703C0069 of the GRAINE program). +`lidaRtRee` development (2018-2021) was funded by the [ADEME](https://www.ademe.fr/en/frontpage/) (french Agency for Ecological Transition) through the [PROTEST](https://protest.inrae.fr/) project (grant 1703C0069 of the GRAINE program). -[<img src="man/figures/logo-ademe-republique-francaise.jpg" alt="logo-ademe-republique-francaise" width="300"/>](https://www.ademe.fr/en) +[<img src="man/figures/logo-ademe-republique-francaise.jpg" alt="logo-ademe-republique-francaise" width="300"/>](https://www.ademe.fr/en/frontpage/) <br> [<img src="man/figures/logo_inrae.png" alt="logo_inrae" width="330"/>](https://www.inrae.fr/en) diff --git a/man/aba_build_model.Rd b/man/aba_build_model.Rd index 363b2c1e6bf15083c4cc0280cc8a159f5c728cdf..c8738426f2ab82a702341a2752af532e00fa3d77 100755 --- a/man/aba_build_model.Rd +++ b/man/aba_build_model.Rd @@ -11,7 +11,8 @@ aba_build_model( nmax = 3, test = c("partial_p", "vif", "gvlma"), xy = NULL, - threshold = NULL + threshold = NULL, + ... ) } \arguments{ @@ -35,7 +36,11 @@ observations: not used in the function but exported in the result for use in further inference functions} \item{threshold}{vector of length two. minimum and maximum values of threshold -to apply to predicted values} +to apply to predicted values. Non-finite values are replaced by the minimum. +Values are replaced after computation of the variance of residuals used for +bias correction} + +\item{...}{other parameters to be passed to \code{\link[leaps]{regsubsets}},} } \value{ a list with three elements diff --git a/man/aba_predict.Rd b/man/aba_predict.Rd index 5d811183eb841012723132e8c5348bace8685dc7..fd9183d6c23efe0b8bb90d068dddd247a94ba713 100755 --- a/man/aba_predict.Rd +++ b/man/aba_predict.Rd @@ -9,7 +9,8 @@ aba_predict( metrics_map, stratum = NULL, add_error = FALSE, - pkg = "terra" + pkg = "terra", + ... ) } \arguments{ @@ -29,6 +30,8 @@ N(0, sigma(residuals)) should be added to fitted values; implemented only for \item{pkg}{raster output format. Use pkg = "terra|raster|stars" to get an output in SpatRaster, RasterLayer or stars format.} + +\item{...}{other parameters to be passed to \code{\link[stats]{predict.lm}}, e.g. \code{interval = "prediction"},} } \value{ a raster of predictions obtained by applying the model \code{aba_build_model} diff --git a/man/add_vegetation_indices.Rd b/man/add_vegetation_indices.Rd index 54788bfbf8862a92b111f74930beebeb3fa3f264..9caa5c8aad3bdd45454e160577c9dd41f858312d 100755 --- a/man/add_vegetation_indices.Rd +++ b/man/add_vegetation_indices.Rd @@ -21,7 +21,7 @@ a raster or data.frame with added bands or columns \description{ Computes vegetation indices from the Red, Green and Infra-Red bands of an IRC image and adds them as additional bands or columns. Acronyms are listed on -\url{https://www.l3harrisgeospatial.com/docs/broadbandgreenness.html}. If the +\url{https://www.nv5geospatialsoftware.com/docs/BroadbandGreenness.html}. If the Blue band is also present, additional indices are computed. } \examples{ diff --git a/man/convert_raster.Rd b/man/convert_raster.Rd index 18a8ec4cfa83788bb5f2df53edfba109ccf3d0f1..a4252804a315252b9754ddbe9f1ca9296c2d9151 100755 --- a/man/convert_raster.Rd +++ b/man/convert_raster.Rd @@ -10,7 +10,7 @@ convert_raster(r, pkg = NULL) \item{r}{raster object or file name.} \item{pkg}{package name. Use pkg = "terra| -raster|stars" to get an output in SpatRaster, RasterLayer or stars format} +stars" to get an output in SpatRaster or stars format} } \value{ A raster object in the specified format @@ -29,13 +29,6 @@ chm_chablais3 <- terra::rast(chm_chablais3) # to stars # chm_stars <- convert_raster(chm_chablais3, pkg = "stars") # chm_stars +# convert_raster(chm_stars, pkg = "terra") # } -if (require("raster")) -{ -# to raster -chm_raster <- convert_raster(chm_chablais3, pkg = "raster") -chm_raster -# back to terra -convert_raster(chm_raster, pkg = "terra") -} }