Skip to content

Commit

Permalink
Merge pull request #331 from r-spatialecology/main
Browse files Browse the repository at this point in the history
landscapemetrics v2.1.4
  • Loading branch information
mhesselbarth authored Jul 22, 2024
2 parents a77e718 + caaed12 commit 8c31a0a
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 6 deletions.
4 changes: 2 additions & 2 deletions 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.3
Version: 2.1.4
Authors@R: c(person("Maximilian H.K.", "Hesselbarth",
role = c("aut", "cre"),
email = "mhk.hesselbarth@gmail.com",
Expand Down Expand Up @@ -76,5 +76,5 @@ Encoding: UTF-8
LazyData: true
Config/testthat/edition: 3
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
VignetteBuilder: knitr
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

S3method(landscape_as_list,PackedSpatRaster)
S3method(landscape_as_list,RasterBrick)
S3method(landscape_as_list,RasterLayer)
S3method(landscape_as_list,RasterStack)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# landscapemetrics 2.1.4
* Various
* Adding `landscape_as_list()` method for `PackedSpatRaster`

# landscapemetrics 2.1.3
* Bugfixes
* Fixed bug in `get_centroids()` related to the patch id
Expand Down
14 changes: 14 additions & 0 deletions R/landscape_as_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ landscape_as_list <- function(landscape) UseMethod("landscape_as_list")
#' @name landscape_as_list
#' @export
landscape_as_list.SpatRaster <- function(landscape) {

landscape <- terra::as.list(landscape)

return(landscape)
Expand Down Expand Up @@ -87,3 +88,16 @@ landscape_as_list.numeric <- function(landscape) {

return(landscape)
}

#' @name landscape_as_list
#' @export
landscape_as_list.PackedSpatRaster <- function(landscape) {

landscape <- terra::unwrap(landscape)
landscape <- terra::as.list(landscape)

warning("Unwrapped Packed* input object.", call. = FALSE)

return(landscape)

}
6 changes: 3 additions & 3 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"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.3",
"version": "2.1.4",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.4.0 (2024-04-24)",
"runtimePlatform": "R version 4.4.1 (2024-06-14)",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand Down Expand Up @@ -303,7 +303,7 @@
},
"SystemRequirements": null
},
"fileSize": "1743.581KB",
"fileSize": "1746.291KB",
"citation": [
{
"@type": "ScholarlyArticle",
Expand Down
5 changes: 4 additions & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# landscapemetrics 2.1.4
Minor feature improvments

# landscapemetrics 2.1.3
* Improve documentation and minor bugfixes
* This is a re-submission. The below error has now been fixed
`Please provide package anchors for all Rd \link{} targets`
* Improve documentation and minor bugfixes

# landscapemetrics 2.1.2
Minor bugfixes
Expand Down
3 changes: 3 additions & 0 deletions man/landscape_as_list.Rd

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

1 change: 1 addition & 0 deletions tests/testthat/test-landscape_as_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ test_that("landscape_as_list returns a list", {
expect_type(landscape_as_list(landscape_stack), "list")
expect_type(landscape_as_list(landscape_list), "list")
expect_type(landscape_as_list(landscape_matrix), "list")
expect_type(landscape_as_list(terra::wrap(landscape)), "list")

})

0 comments on commit 8c31a0a

Please sign in to comment.