Skip to content

Commit

Permalink
Merge pull request #313 from r-spatialecology/main
Browse files Browse the repository at this point in the history
v2.1.1
  • Loading branch information
mhesselbarth authored Jan 4, 2024
2 parents cf09eca + 2ae9d20 commit 2c2bb29
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: landscapemetrics
Title: Landscape Metrics for Categorical Map Patterns
Version: 2.1.0
Version: 2.1.1
Authors@R: c(person("Maximilian H.K.", "Hesselbarth",
role = c("aut", "cre"),
email = "mhk.hesselbarth@gmail.com",
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# landscapemetrics 2.1.1
* Bugfixes
* Bugfix in calculate of clumpy if NA values are present
* Bugfix in construct_buffer that CRS was lost

# landscapemetrics 2.1.0
* Improvements
* Many performance improvements. Most visible are in
Expand Down
5 changes: 3 additions & 2 deletions R/construct_buffer.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' @param size Size of sample plot. Equals the radius for circles or the
#' side-length for squares in map units
#' @param return_vec If TRUE, vector objects are returned.
#' @param crs The coordinate reference system used for vector objects.
#' @param verbose Print warning messages.
#'
#' @return
Expand All @@ -22,7 +23,7 @@
#' @keywords internal
#'
#' @export
construct_buffer <- function(coords, shape , size, return_vec = TRUE, verbose = TRUE) {
construct_buffer <- function(coords, shape , size, return_vec = TRUE, crs="", verbose = TRUE) {

# make sure coords are matrix
coords <- points_as_mat(pts = coords)
Expand Down Expand Up @@ -80,7 +81,7 @@ construct_buffer <- function(coords, shape , size, return_vec = TRUE, verbose =

mat <- matrix(x, ncol = 2)

terra::vect(x = mat, type = "polygon")
terra::vect(x = mat, type = "polygon", crs = crs)

})

Expand Down
2 changes: 1 addition & 1 deletion R/lsm_c_clumpy.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ lsm_c_clumpy_calc <- function(landscape, resolution, extras = NULL){
clumpy <- vapply(seq_along(g_i), FUN = function(i) {

# set to NA if mathematical not possible
if (is.nan(g_i[i]) || is.na(g_i[i]) || p_i[i] == 1) numeric(NA)
if (is.nan(g_i[i]) || is.na(g_i[i]) || p_i[i] == 1) as.numeric(NA)
# calc clumpy
else if (g_i[i] >= p_i[i]) (g_i[i] - p_i[i]) / (1 - p_i[i])
else if (g_i[i] < p_i[i] && p_i[i] >= 0.5) (g_i[i] - p_i[i]) / (1 - p_i[i])
Expand Down
5 changes: 4 additions & 1 deletion R/sample_lsm.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,15 @@ sample_lsm_int <- function(landscape, y, plot_id, shape, size,
# convert to terra
y <- methods::as(y, "SpatVector")

# get crs
crs <- terra::crs(y)

if (terra::geomtype(y) == "points") {

if (is.null(size) | size == 0) stop("Please provide size argument size > 0.", call. = FALSE)

y <- construct_buffer(coords = y, shape = shape, size = size,
return_vec = TRUE, verbose = verbose)
return_vec = TRUE, crs = crs, verbose = verbose)

}

Expand Down
4 changes: 2 additions & 2 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"codeRepository": "https://r-spatialecology.github.io/landscapemetrics/",
"issueTracker": "https://github.com/r-spatialecology/landscapemetrics/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "2.1.0",
"version": "2.1.1",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -303,7 +303,7 @@
},
"SystemRequirements": null
},
"fileSize": "1728.419KB",
"fileSize": "1728.517KB",
"citation": [
{
"@type": "ScholarlyArticle",
Expand Down
3 changes: 3 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# landscapemetrics 2.1.1
Minor bugfix

# landscapemetrics 2.1.0
Larger internal updates to several algorithms

Expand Down
11 changes: 10 additions & 1 deletion man/construct_buffer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2c2bb29

Please sign in to comment.