Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
mhesselbarth committed Nov 7, 2019
2 parents 113c8ef + 86a657e commit 23b257a
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 35 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: 1.2.2
Version: 1.3
Authors@R: c(person("Maximillian H.K.", "Hesselbarth",
role = c("aut", "cre"),
email = "[email protected]",
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 1.3
* Bugfixes
* Remove NAs on patch level for shape index

# landscapemetrics 1.2.2
* Bugfixes
* Bug in `lsm_p_circle()` when whole landscape contains only one patch
Expand Down
3 changes: 2 additions & 1 deletion R/lsm_c_shape_cv.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ lsm_c_shape_cv_calc <- function(landscape, directions, resolution = NULL){
resolution = resolution)

# calculate cv
shape_cv <- stats::aggregate(x = shape[, 5], by = shape[, 2], FUN = raster::cv)
shape_cv <- stats::aggregate(x = shape[, 5], by = shape[, 2], FUN = raster::cv,
na.rm = TRUE)

tibble::tibble(
level = "class",
Expand Down
3 changes: 2 additions & 1 deletion R/lsm_c_shape_mn.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ lsm_c_shape_mn_calc <- function(landscape, directions, resolution = NULL){
resolution = resolution)

# calculate mean
shape_mn <- stats::aggregate(x = shape[, 5], by = shape[, 2], FUN = mean)
shape_mn <- stats::aggregate(x = shape[, 5], by = shape[, 2], FUN = mean,
na.rm = TRUE)

tibble::tibble(
level = "class",
Expand Down
3 changes: 2 additions & 1 deletion R/lsm_c_shape_sd.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ lsm_c_shape_sd_calc <- function(landscape, directions, resolution = NULL){
resolution = resolution)

# calculate sd
shape_sd <- stats::aggregate(x = shape[, 5], by = shape[, 2], FUN = stats::sd)
shape_sd <- stats::aggregate(x = shape[, 5], by = shape[, 2], FUN = stats::sd,
na.rm = TRUE)

tibble::tibble(
level = "class",
Expand Down
5 changes: 3 additions & 2 deletions R/lsm_l_shape_cv.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' SHAPE_CV (landscape level)
#'
#' @description Covariance of variation shape index (Shape metric)
#' @description Coefficient of variation shape index (Shape metric)
#'
#' @param landscape Raster* Layer, Stack, Brick or a list of rasterLayers.
#' @param directions The number of directions in which patches should be
Expand Down Expand Up @@ -139,7 +139,8 @@ lsm_l_shape_cv_calc <- function(landscape, directions, resolution = NULL){
resolution = resolution)

# calculate cv
shape_cv <- raster::cv(shape$value)
shape_cv <- raster::cv(shape$value,
na.rm = TRUE)

tibble::tibble(
level = "landscape",
Expand Down
2 changes: 1 addition & 1 deletion R/lsm_l_shape_mn.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ lsm_l_shape_mn_calc <- function(landscape, directions, resolution = NULL){
resolution = resolution)

# calculate mean
shape_mn <- mean(shape$value)
shape_mn <- mean(shape$value, na.rm = TRUE)

tibble::tibble(
level = "landscape",
Expand Down
2 changes: 1 addition & 1 deletion R/lsm_l_shape_sd.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ lsm_l_shape_sd_calc <- function(landscape, directions, resolution = NULL){
resolution = resolution)

# calculate sd
shape_sd <- stats::sd(shape$value)
shape_sd <- stats::sd(shape$value, na.rm = TRUE)

tibble::tibble(
level = "landscape",
Expand Down
14 changes: 9 additions & 5 deletions R/lsm_p_shape.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ lsm_p_shape.list <- function(landscape, directions = 8) {
lsm_p_shape_calc <- function(landscape, directions, resolution = NULL){

# convert to matrix
if (class(landscape) != "matrix"){
if (class(landscape) != "matrix") {
resolution <- raster::res(landscape)
landscape <- raster::as.matrix(landscape)
}
Expand All @@ -157,16 +157,20 @@ lsm_p_shape_calc <- function(landscape, directions, resolution = NULL){

area_patch$m <- area_patch$value - area_patch$n ^ 2

# m should be 0 but is not due to some integer/double numerical issues
area_patch$m[area_patch$m < 0] <- 0

area_patch$minp <- ifelse(test = area_patch$m == 0, yes = area_patch$n * 4,
no = ifelse(test = area_patch$n ^ 2 < area_patch$value & area_patch$value <= area_patch$n * (1 + area_patch$n),
yes = 4 * area_patch$n + 2,
no = ifelse(test = area_patch$value > area_patch$n * (1 + area_patch$n),
yes = 4 * area_patch$n + 4,
no = NA)))
# Throw warning that ifelse didn't work
if(anyNA(area_patch$minp)) {
warning("Calculation of shape index produced NA", call. = FALSE)
}
# this should not be possible anymore
# # Throw warning that ifelse didn't work
# if (anyNA(area_patch$minp)) {
# warning("Calculation of shape index produced NA", call. = FALSE)
# }

tibble::tibble(
level = "patch",
Expand Down
14 changes: 10 additions & 4 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ status](https://codecov.io/gh/r-spatialecology/landscapemetrics/branch/master/gr

**landscapemetrics** supports `raster` spatial objects and takes `RasterLayer`, `RasterStacks`, `RasterBricks` or lists of `RasterLayer` as input arguments. Every function can be used in a piped workflow, as it always takes the data as the first argument and returns a tibble.

### Citation

To cite `landscapemetrics` or acknowledge its use, please cite the
following Software note, substituting the version of the application
that you used for ‘version 0’: Hesselbarth, M.H.K., Sciaini, M., With,
K.A., Wiegand, K., Nowosad, J. 2019. landscapemetrics: an open-source R
tool to calculate landscape metrics. - Ecography 42:1648-1657 (ver. 0).

For more information see [Publication record](https://r-spatialecology.github.io/landscapemetrics/articles/articles/publication_record.html) vignette. The get a BibTex entry, please use `citation("landscapemetrics")`.

## Installation

There are several ways to install **landscapemetrics**:
Expand Down Expand Up @@ -123,10 +133,6 @@ One of the major motivations behind **landscapemetrics** is the idea to provide

Maintainers and contributors must follow this repository’s [CODE OF CONDUCT](CODE_OF_CONDUCT.md).

### Citation

To cite `landscapemetrics` or acknowledge its use, please cite the following Software note, substituting the version of the application that you used for ‘version 0’: Hesselbarth, M.H.K., Sciaini, M., With, K.A., Wiegand, K., Nowosad, J. 2019. landscapemetrics: an open-source R tool to calculate landscape metrics. - Ecography 42:1-10 (ver. 0). For more information see [Publication record](https://r-spatialecology.github.io/landscapemetrics/articles/articles/publication_record.html) vignette.

### References

- McGarigal, K., Cushman, S.A., and Ene E. 2012. FRAGSTATS v4: Spatial Pattern Analysis Program for Categorical and Continuous Maps. Computer software program produced by the authors at the University of Massachusetts, Amherst. Available at the following website: <http://www.umass.edu/landeco/research/fragstats/fragstats.html>
Expand Down
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ Stepinski 2019).
as input arguments. Every function can be used in a piped workflow, as
it always takes the data as the first argument and returns a tibble.

### Citation

To cite `landscapemetrics` or acknowledge its use, please cite the
following Software note, substituting the version of the application
that you used for ‘version 0’: Hesselbarth, M.H.K., Sciaini, M., With,
K.A., Wiegand, K., Nowosad, J. 2019. landscapemetrics: an open-source R
tool to calculate landscape metrics. - Ecography 42:1648-1657 (ver. 0).

For more information see [Publication
record](https://r-spatialecology.github.io/landscapemetrics/articles/articles/publication_record.html)
vignette. The get a BibTex entry, please use
`citation("landscapemetrics")`.

## Installation

There are several ways to install **landscapemetrics**:
Expand Down Expand Up @@ -124,7 +137,7 @@ lsm_p_enn(landscape)
#> 8 1 patch 1 8 enn 2
#> 9 1 patch 1 9 enn 4.12
#> 10 1 patch 2 10 enn 4.47
#> # ... with 17 more rows
#> # with 17 more rows

# calculate the total area and total class edge length
lsm_l_ta(landscape)
Expand Down Expand Up @@ -161,13 +174,13 @@ calculate_lsm(landscape, level = "patch")
#> 8 1 patch 1 8 area 0.0001
#> 9 1 patch 1 9 area 0.0003
#> 10 1 patch 2 10 area 0.0035
#> # ... with 314 more rows
#> # with 314 more rows
```

### Utility functions

**landscapemetrics** further provides several visualization functions,
e.g. show all labeld patches or the core area of all patches. All
e.g. show all labeled patches or the core area of all patches. All
visualization functions start with the prefix `show_`
(e.g. `show_cores()`).

Expand All @@ -193,17 +206,6 @@ warmly welcome to do so\! For more information see
Maintainers and contributors must follow this repository’s [CODE OF
CONDUCT](CODE_OF_CONDUCT.md).

### Citation

To cite `landscapemetrics` or acknowledge its use, please cite the
following Software note, substituting the version of the application
that you used for ‘version 0’: Hesselbarth, M.H.K., Sciaini, M., With,
K.A., Wiegand, K., Nowosad, J. 2019. landscapemetrics: an open-source R
tool to calculate landscape metrics. - Ecography 42:1-10 (ver. 0). For
more information see [Publication
record](https://r-spatialecology.github.io/landscapemetrics/articles/articles/publication_record.html)
vignette.

### References

- McGarigal, K., Cushman, S.A., and Ene E. 2012. FRAGSTATS v4: Spatial
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 @@
## Update Version: 1.3
Minor bugfixes

## Update Version: 1.2.2
Small bugfixes and improvments of existing functions

Expand Down
4 changes: 2 additions & 2 deletions inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ citEntry(
journal = {"Ecography"},
volume = {"42"},
year = {"2019"},
pages = {"1-10"},
textVersion = "Hesselbarth, M.H.K., Sciaini, M., With, K.A., Wiegand, K., Nowosad, J. 2019. landscapemetrics: an open-source R tool to calculate landscape metrics. - Ecography 42:1-10 (ver. 0).")
pages = {"1648-1657"},
textVersion = "Hesselbarth, M.H.K., Sciaini, M., With, K.A., Wiegand, K., Nowosad, J. 2019. landscapemetrics: an open-source R tool to calculate landscape metrics. - Ecography 42:1648-1657(ver. 0).")
Binary file modified man/figures/README-unnamed-chunk-1-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion man/lsm_l_shape_cv.Rd

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

2 changes: 1 addition & 1 deletion vignettes/articles/publication_record.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ output:

We try to maintain a list of publications that have used the `landscapemetrics` package. If you have used `landscapemetrics` in your own work, we would love to hear from you. Please [file an issue on GitHub](https://github.com/r-spatialecology/landscapemetrics/issues/new/) so we can add your work to this list.

To cite `landscapemetrics` or acknowledge its use, please cite the following Software note, substituting the version of the application that you used for ‘version 0’: Hesselbarth, M.H.K., Sciaini, M., With, K.A., Wiegand, K., Nowosad, J. 2019. landscapemetrics: an open-source R tool to calculate landscape metrics. - Ecography 42:1-10 (ver. 0).
To cite `landscapemetrics` or acknowledge its use, please cite the following Software note, substituting the version of the application that you used for ‘version 0’: Hesselbarth, M.H.K., Sciaini, M., With, K.A., Wiegand, K., Nowosad, J. 2019. landscapemetrics: an open-source R tool to calculate landscape metrics. - Ecography 42:1648-1657 (ver. 0).

## A list of publications

Expand Down

0 comments on commit 23b257a

Please sign in to comment.