Skip to content

Commit c1c8bd9

Browse files
committed
# biodivMapR2 v2.4.5
## change - biodivMapR_full_classif: add possibility to set compute_beta = TRUE or FALSE - remove TODO.md - use regular expression '\\.' when searching for strings including '.': - define 'get_samples_from_tiles' in independent file
1 parent bed6b0d commit c1c8bd9

File tree

6 files changed

+45
-7
lines changed

6 files changed

+45
-7
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export(get_raster_diversity)
5858
export(get_raster_diversity_mw)
5959
export(get_raster_diversity_tile)
6060
export(get_raster_extent)
61+
export(get_samples_from_plots)
6162
export(get_samples_from_tiles)
6263
export(get_si_tiles_from_raster)
6364
export(get_spectralSpecies)

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- biodivMapR_full_classif: add possibility to set compute_beta = TRUE or FALSE
44
- remove TODO.md
55
- use regular expression '\\.' when searching for strings including '.':
6+
- define 'get_samples_from_tiles' in independent file
67

78
# biodivMapR2 v2.4.4
89
## fix

R/biodivMapR_full_classif.R

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#'
1212
#' @return diversity_maps_ground
1313
#' @importFrom dissUtils diss
14+
#' @importFrom terra vect crs rast extract values aggregate writeRaster
1415
#' @export
1516

1617
biodivMapR_full_classif <- function(input_raster_path, output_dir, window_size,
@@ -41,12 +42,6 @@ biodivMapR_full_classif <- function(input_raster_path, output_dir, window_size,
4142

4243
plots_beta <- plots[sample(x = seq_along(plots), nb_samples_beta,
4344
replace = FALSE)]
44-
get_samples_from_plots <- function(x, y){
45-
x <- terra::vect(x)
46-
res <- terra::extract(x = y, y = x, raw = TRUE, ID = FALSE)
47-
res <- c(unlist(res))
48-
return(res)
49-
}
5045
samples <- lapply(X = plots_beta, FUN = get_samples_from_plots,
5146
y = terra::rast(input_raster_path))
5247

@@ -95,6 +90,12 @@ biodivMapR_full_classif <- function(input_raster_path, output_dir, window_size,
9590
alpha_metrics = alpha_metrics,
9691
Hill_order = 1, pcelim = pcelim)
9792
cell_order <- unlist(lapply(extracted_val, '[[', 'cell'))
93+
if (is.null(Beta_info)){
94+
elim <- which(names(alphabeta)=='PCoA_BC')
95+
if (length(elim) > 0)
96+
alphabeta <- alphabeta[-elim]
97+
}
98+
9899

99100
# save diversity maps
100101
diversity_maps_ground <- list()

R/define_grid.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
define_grid <- function(raster_path, cellsize){
1010
rast_obj <- terra::rast(raster_path)[[1]]
11-
mask_polygon <- terra::as.polygons(x = terra::ext(rast_obj))
11+
mask_polygon <- terra::as.polygons(x = terra::ext(rast_obj),
12+
crs=terra::crs(rast_obj))
1213
aoi <- sf::st_as_sf(mask_polygon, quiet = T)
1314
crs_init <- sf::st_crs(aoi)
1415
aoi <- sf::st_multipolygon(aoi$geometry)

R/get_samples_from_plots.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#' extracts samples defined by a vector layer from a raster
2+
#'
3+
#' @param x spatVector vector layer
4+
#' @param y spatRaster raster
5+
#'
6+
#' @return res
7+
#' @importFrom terra vect extract
8+
#' @export
9+
#'
10+
get_samples_from_plots <- function(x, y){
11+
x <- terra::vect(x)
12+
res <- terra::extract(x = y, y = x, raw = TRUE, ID = FALSE)
13+
res <- c(unlist(res))
14+
return(res)
15+
}

man/get_samples_from_plots.Rd

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)