Skip to content

Commit

Permalink
Merge pull request #221 from r-spatialecology/main
Browse files Browse the repository at this point in the history
v1.5.2
  • Loading branch information
mhesselbarth authored Feb 4, 2021
2 parents ac0a002 + d438017 commit 3b32508
Show file tree
Hide file tree
Showing 18 changed files with 139 additions and 115 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/Deploy-pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ on:
push:
branches:
- CRAN
- master
- main

name: Deploy-pkgdown

Expand All @@ -13,11 +13,14 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1

- uses: r-lib/actions/setup-pandoc@v1

- name: Setup R
uses: r-lib/actions/setup-r@master
with:
crayon.enabled: 'FALSE'

- name: Query dependencies
run: |
install.packages('remotes')
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ on:
push:
branches:
- CRAN
- master
- main
pull_request:
branches:
- CRAN
- master
- main

name: R-CMD-check

jobs:
R-CMD-check:
if: "!contains(github.event.commits[0].message, '[skip-ci]')"
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/Render-README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,23 @@ jobs:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-pandoc@v1

- name: Setup R
uses: r-lib/actions/setup-r@master
with:
crayon.enabled: 'FALSE'

- name: Install rmarkdown, remotes, and the local package
run: |
install.packages("remotes")
remotes::install_local(".")
remotes::install_cran("rmarkdown")
remotes::install_cran("landscapetools")
shell: Rscript {0}

- name: Render README
run: Rscript -e 'rmarkdown::render("README.Rmd")'

- name: Commit results
run: |
git config --local user.email "[email protected]"
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/Test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ on:
push:
branches:
- CRAN
- master
- main
pull_request:
branches:
- CRAN
- master
- main

name: Test-coverage

jobs:
test-coverage:
if: "!contains(github.event.commits[0].message, '[skip-ci]')"
runs-on: macOS-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Before making any changes, make sure to pull changes in from upstream by either
4. Make your changes (bonus points for making changes on a new branch)
5. If you alter package functionality at all (e.g., the code itself, not just documentation) please do write some tests to cover the new functionality.
6. Push changes to your account
7. Submit a pull request to the master branch at `r-spatialecology/landscapemetrics`
7. Submit a pull request to the main branch at `r-spatialecology/landscapemetrics`

### Questions? Get in touch: [[email protected]](mailto:[email protected]) or [[email protected]](mailto:[email protected])

Expand Down
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.5.1
Version: 1.5.2
Authors@R: c(person("Maximillian H.K.", "Hesselbarth",
role = c("aut", "cre"),
email = "[email protected]",
Expand Down
10 changes: 8 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# landscapemetrics 1.5.2
* Bugfixes
* Bug in `lsm_l_ai` if class with only one cell exists
* Various
* Renamed master to main branch

# landscapemetrics 1.5.1
* Improvements
* Use GitHub actions
* Bugfixes
* Bug in `lsm_c_lsi`, `lsm_c_nlsi`, `lsm_l_lsi` not using cell surfaces
* Bug in `lsm_c_lsi`, `lsm_c_nlsi`, `lsm_l_lsi` not using cell surfaces

# landscapemetrics 1.5.0
* Improvements
Expand All @@ -23,7 +29,7 @@
* `get_nearestneighbour()` can now return ID of neighbouring patch
* `get_boundaries()` allows now to specify edge depth
* `get_boundaries()` can return the patch id for edge cells
* New gunctions
* New functions
* `get_centroid()` returns the coordinates of each patch centroid

# landscapemetrics 1.4.4
Expand Down
2 changes: 1 addition & 1 deletion R/lsm_c_ai.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ lsm_c_ai_calc <- function(landscape) {
# calculate aggregation index
ai <- (like_adjacencies / max_adj) * 100

# if NaN (mathematical reason) set to NA
# max_adj can be zero if only one cell is present; set to NA
ai[is.nan(ai)] <- NA

return(tibble::tibble(level = "class",
Expand Down
4 changes: 2 additions & 2 deletions R/lsm_l_ai.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' AI is an 'Aggregation metric'. It equals the number of like adjacencies divided
#' by the theoretical maximum possible number of like adjacencies for that class summed over each
#' class for the entire landscape.
#' The metric is based on he adjacency matrix and the the single-count method.
#' The metric is based on he adjacency matrix and the single-count method.
#'
#' \subsection{Units}{Percent}
#' \subsection{Range}{0 <= AI <= 100}
Expand Down Expand Up @@ -82,7 +82,7 @@ lsm_l_ai_calc <- function(landscape, resolution = NULL) {
resolution = resolution)

# final AI index
result <- sum(ai$value * (pland$value / 100))
result <- sum(ai$value * (pland$value / 100), na.rm = TRUE)

return(tibble::tibble(level = "landscape",
class = as.integer(NA),
Expand Down
16 changes: 9 additions & 7 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
output:
github_document:
html_preview: false
editor_options:
chunk_output_type: console
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/REAsDME-",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
Expand All @@ -18,7 +20,7 @@ knitr::opts_chunk$set(
| Continuous Integration | Development | CRAN | License |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|
| ![R-CMD-check](https://github.com/r-spatialecology/landscapemetrics/workflows/R-CMD-check/badge.svg) | [![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable) | [![CRAN status](https://www.r-pkg.org/badges/version/landscapemetrics)](https://cran.r-project.org/package=landscapemetrics) | [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) |
| [![Coverage](https://codecov.io/gh/r-spatialecology/landscapemetrics/branch/master/graph/badge.svg)](https://codecov.io/github/r-spatialecology/landscapemetrics?branch=master) | [![Project Status](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) | [![CRAN downloads](http://cranlogs.r-pkg.org/badges/grand-total/landscapemetrics)](http://cran.rstudio.com/web/packages/landscapemetrics/index.html) | [![DOI](https://img.shields.io/badge/DOI-10.1111/ecog.04617-blue.svg)](https://doi.org/10.1111/ecog.04617) |
| [![Coverage](https://codecov.io/gh/r-spatialecology/landscapemetrics/branch/main/graph/badge.svg)](https://codecov.io/github/r-spatialecology/landscapemetrics?branch=main) | [![Project Status](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) | [![CRAN downloads](http://cranlogs.r-pkg.org/badges/grand-total/landscapemetrics)](http://cran.rstudio.com/web/packages/landscapemetrics/index.html) | [![DOI](https://img.shields.io/badge/DOI-10.1111/ecog.04617-blue.svg)](https://doi.org/10.1111/ecog.04617) |

# landscapemetrics <img src="man/figures/logo.png" align="right" width="150" />

Expand All @@ -45,13 +47,13 @@ For more information see [Publication record](https://r-spatialecology.github.io

There are several ways to install **landscapemetrics**:

```r
```{r, eval = FALSE, echo = TRUE}
# Get the stable version from CRAN
install.packages("landscapemetrics")
# Alternatively, you can install the development version from Github
# install.packages("devtools")
devtools::install_github("r-spatialecology/landscapemetrics")
# install.packages("remotes")
remotes::install_github("r-spatialecology/landscapemetrics")
```

#### Announcement
Expand Down Expand Up @@ -92,7 +94,7 @@ All functions return an identical structured tibble:

Every function follows the same implementation design, so the usage is quite straightforward:

```{r, message=FALSE, warning=FALSE}
```{r, message = FALSE, warning = FALSE}
library(landscapemetrics)
library(landscapetools)
Expand All @@ -109,7 +111,7 @@ lsm_c_te(landscape)

There is also a wrapper around every metric in the package to quickly calculate a bunch of metrics:

```{r, message=FALSE}
```{r, message = FALSE}
# calculate all metrics on patch level
calculate_lsm(landscape, level = "patch")
```
Expand Down
82 changes: 41 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

| Continuous Integration | Development | CRAN | License |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| ![R-CMD-check](https://github.com/r-spatialecology/landscapemetrics/workflows/R-CMD-check/badge.svg) | [![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable) | [![CRAN status](https://www.r-pkg.org/badges/version/landscapemetrics)](https://cran.r-project.org/package=landscapemetrics) | [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) |
| [![Coverage](https://codecov.io/gh/r-spatialecology/landscapemetrics/branch/master/graph/badge.svg)](https://codecov.io/github/r-spatialecology/landscapemetrics?branch=master) | [![Project Status](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) | [![CRAN downloads](http://cranlogs.r-pkg.org/badges/grand-total/landscapemetrics)](http://cran.rstudio.com/web/packages/landscapemetrics/index.html) | [![DOI](https://img.shields.io/badge/DOI-10.1111/ecog.04617-blue.svg)](https://doi.org/10.1111/ecog.04617) |
| Continuous Integration | Development | CRAN | License |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| ![R-CMD-check](https://github.com/r-spatialecology/landscapemetrics/workflows/R-CMD-check/badge.svg) | [![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable) | [![CRAN status](https://www.r-pkg.org/badges/version/landscapemetrics)](https://cran.r-project.org/package=landscapemetrics) | [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) |
| [![Coverage](https://codecov.io/gh/r-spatialecology/landscapemetrics/branch/main/graph/badge.svg)](https://codecov.io/github/r-spatialecology/landscapemetrics?branch=main) | [![Project Status](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) | [![CRAN downloads](http://cranlogs.r-pkg.org/badges/grand-total/landscapemetrics)](http://cran.rstudio.com/web/packages/landscapemetrics/index.html) | [![DOI](https://img.shields.io/badge/DOI-10.1111/ecog.04617-blue.svg)](https://doi.org/10.1111/ecog.04617) |

# landscapemetrics <img src="man/figures/logo.png" align="right" width="150" />

Expand Down Expand Up @@ -52,8 +52,8 @@ There are several ways to install **landscapemetrics**:
install.packages("landscapemetrics")

# Alternatively, you can install the development version from Github
# install.packages("devtools")
devtools::install_github("r-spatialecology/landscapemetrics")
# install.packages("remotes")
remotes::install_github("r-spatialecology/landscapemetrics")
```

#### Announcement
Expand Down Expand Up @@ -113,40 +113,40 @@ library(landscapetools)
show_landscape(landscape)
```

<img src="man/figures/REAsDME-unnamed-chunk-1-1.png" width="100%" />
<img src="man/figures/README-unnamed-chunk-2-1.png" width="100%" />

``` r

# calculate for example the Euclidean nearest-neighbor distance on patch level
lsm_p_enn(landscape)
#> [90m# A tibble: 27 x 6[39m
#> # A tibble: 27 x 6
#> layer level class id metric value
#> [3m[90m<int>[39m[23m [3m[90m<chr>[39m[23m [3m[90m<int>[39m[23m [3m[90m<int>[39m[23m [3m[90m<chr>[39m[23m [3m[90m<dbl>[39m[23m
#> [90m 1[39m 1 patch 1 1 enn 7
#> [90m 2[39m 1 patch 1 2 enn 4
#> [90m 3[39m 1 patch 1 3 enn 2.83
#> [90m 4[39m 1 patch 1 4 enn 2
#> [90m 5[39m 1 patch 1 5 enn 2
#> [90m 6[39m 1 patch 1 6 enn 2.83
#> [90m 7[39m 1 patch 1 7 enn 4.12
#> [90m 8[39m 1 patch 1 8 enn 4.12
#> [90m 9[39m 1 patch 1 9 enn 4.24
#> [90m10[39m 1 patch 2 10 enn 4.47
#> [90m# … with 17 more rows[39m
#> <int> <chr> <int> <int> <chr> <dbl>
#> 1 1 patch 1 1 enn 7
#> 2 1 patch 1 2 enn 4
#> 3 1 patch 1 3 enn 2.83
#> 4 1 patch 1 4 enn 2
#> 5 1 patch 1 5 enn 2
#> 6 1 patch 1 6 enn 2.83
#> 7 1 patch 1 7 enn 4.12
#> 8 1 patch 1 8 enn 4.12
#> 9 1 patch 1 9 enn 4.24
#> 10 1 patch 2 10 enn 4.47
#> # … with 17 more rows

# calculate the total area and total class edge length
lsm_l_ta(landscape)
#> [90m# A tibble: 1 x 6[39m
#> # A tibble: 1 x 6
#> layer level class id metric value
#> [3m[90m<int>[39m[23m [3m[90m<chr>[39m[23m [3m[90m<int>[39m[23m [3m[90m<int>[39m[23m [3m[90m<chr>[39m[23m [3m[90m<dbl>[39m[23m
#> [90m1[39m 1 landscape [31mNA[39m [31mNA[39m ta 0.09
#> <int> <chr> <int> <int> <chr> <dbl>
#> 1 1 landscape NA NA ta 0.09
lsm_c_te(landscape)
#> [90m# A tibble: 3 x 6[39m
#> # A tibble: 3 x 6
#> layer level class id metric value
#> [3m[90m<int>[39m[23m [3m[90m<chr>[39m[23m [3m[90m<int>[39m[23m [3m[90m<int>[39m[23m [3m[90m<chr>[39m[23m [3m[90m<dbl>[39m[23m
#> [90m1[39m 1 class 1 [31mNA[39m te 180
#> [90m2[39m 1 class 2 [31mNA[39m te 227
#> [90m3[39m 1 class 3 [31mNA[39m te 321
#> <int> <chr> <int> <int> <chr> <dbl>
#> 1 1 class 1 NA te 180
#> 2 1 class 2 NA te 227
#> 3 1 class 3 NA te 321
```

There is also a wrapper around every metric in the package to quickly
Expand All @@ -156,20 +156,20 @@ calculate a bunch of metrics:
# calculate all metrics on patch level
calculate_lsm(landscape, level = "patch")
#> Warning: Please use 'check_landscape()' to ensure the input data is valid.
#> [90m# A tibble: 324 x 6[39m
#> # A tibble: 324 x 6
#> layer level class id metric value
#> [3m[90m<int>[39m[23m [3m[90m<chr>[39m[23m [3m[90m<int>[39m[23m [3m[90m<int>[39m[23m [3m[90m<chr>[39m[23m [3m[90m<dbl>[39m[23m
#> [90m 1[39m 1 patch 1 1 area 0.000[4m1[24m
#> [90m 2[39m 1 patch 1 2 area 0.000[4m5[24m
#> [90m 3[39m 1 patch 1 3 area 0.014[4m8[24m
#> [90m 4[39m 1 patch 1 4 area 0.000[4m1[24m
#> [90m 5[39m 1 patch 1 5 area 0.000[4m1[24m
#> [90m 6[39m 1 patch 1 6 area 0.001[4m4[24m
#> [90m 7[39m 1 patch 1 7 area 0.000[4m3[24m
#> [90m 8[39m 1 patch 1 8 area 0.000[4m5[24m
#> [90m 9[39m 1 patch 1 9 area 0.000[4m1[24m
#> [90m10[39m 1 patch 2 10 area 0.003[4m5[24m
#> [90m# … with 314 more rows[39m
#> <int> <chr> <int> <int> <chr> <dbl>
#> 1 1 patch 1 1 area 0.0001
#> 2 1 patch 1 2 area 0.0005
#> 3 1 patch 1 3 area 0.0148
#> 4 1 patch 1 4 area 0.0001
#> 5 1 patch 1 5 area 0.0001
#> 6 1 patch 1 6 area 0.0014
#> 7 1 patch 1 7 area 0.0003
#> 8 1 patch 1 8 area 0.0005
#> 9 1 patch 1 9 area 0.0001
#> 10 1 patch 2 10 area 0.0035
#> # … with 314 more rows
```

### Utility functions
Expand Down
Loading

0 comments on commit 3b32508

Please sign in to comment.