forked from ropensci/landscapetools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
129 lines (97 loc) · 4.79 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
---
output:
github_document:
html_preview: false
---
[![Travis build status](https://travis-ci.org/ropensci/landscapetools.svg?branch=master)](https://travis-ci.org/ropensci/landscapetools)
[![Build status](https://ci.appveyor.com/api/projects/status/aehfkxfb5r4vjlm9?svg=true)](https://ci.appveyor.com/project/ropensci/landscapetools)
[![codecov](https://codecov.io/gh/ropensci/landscapetools/branch/develop/graph/badge.svg)](https://codecov.io/gh/ropensci/landscapetools)
[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)
[![CRAN status](https://www.r-pkg.org/badges/version/landscapetools)](https://cran.r-project.org/package=landscapetools)
[![](http://cranlogs.r-pkg.org/badges/grand-total/landscapetools)](http://cran.rstudio.com/web/packages/landscapetools/index.html)
[![](https://badges.ropensci.org/188_status.svg)](https://github.com/ropensci/onboarding/issues/188)
[![DOI:10.1111/2041-210X.13076](https://zenodo.org/badge/DOI/10.1111/2041-210X.13076.svg)](https://doi.org/10.1111/2041-210X.13076)
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# landscapetools
`landscapetools` provides utility functions to work with landscape data (raster*
Objects).
### The following functions are implemented:
#### Utilities:
`util_binarize`: Binarize continuous raster values, if > 1 breaks are given, return a RasterBrick.<br/>
`util_classify`: Classify a raster into proportions based upon a vector of class weightings.<br/>
`util_merge`: Merge a primary raster with other rasters weighted by scaling factors.<br/>
`util_raster2tibble`, `util_tibble2raster`: Coerce raster* objects to tibbles and vice versa.<br/>
`util_rescale`: Linearly rescale element values in a raster to a range between 0 and 1.<br/>
#### Visualization
`util_plot`: Plot a Raster* object with the landscapetools default theme (as ggplot).<br/>
`util_facetplot`: Plot multiple raster (RasterStack, -brick or list of raster) side by side as facets.<br/>
#### Themes:
`theme_nlm`, `theme_nlm_grey`: Opinionated ggplot2 theme to visualize raster (continuous data).<br/>
`theme_nlm_discrete`, `theme_nlm_grey_discrete`: Opinionated ggplot2 theme to visualize raster (discrete data).<br/>
`theme_faceplot`: Opinionated ggplot2 theme to visualize raster in a facet wrap.<br/>
`util_import_roboto_condensed`: Import Roboto Condensed font for `theme_nlm`.<br/>
## Installation
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("ropensci/landscapetools")
```
## Usage
```{r fig.retina=2}
library(NLMR)
library(landscapetools)
# Create an artificial landscape
nlm_raster <- nlm_fbm(ncol = 200, nrow = 200, fract_dim = 0.8)
util_plot(nlm_raster)
```
## Utilities
### Binarize
```{r fig.retina=2}
# Binarize the map into habitat and matrix
binarized_raster <- util_binarize(nlm_raster, breaks = 0.31415)
util_plot(binarized_raster, discrete = TRUE)
```
### Classify
```{r fig.retina=2}
# Classify the map into land uses
classified_raster <- util_classify(nlm_raster,
n = 3,
level_names = c("Land Use 1", "Land Use 2", "Land Use 3"))
util_plot(classified_raster, discrete = TRUE)
```
### Merge
```{r fig.retina=2}
# Create a primary and two secondary maps
prim <- nlm_edgegradient(ncol = 100, nrow = 100)
sec1 <- nlm_distancegradient(ncol = 100, nrow = 100,
origin = c(10, 10, 10, 10))
sec2 <- nlm_random(ncol = 100, nrow = 100)
# Merge all maps into one
merg <- util_merge(prim, c(sec1, sec2), scalingfactor = 1)
# Plot an overview
merge_vis <- list(
"1) Primary" = prim,
"2) Secondary 1" = sec1,
"3) Secondary 2" = sec2,
"4) Result" = merg
)
util_facetplot(merge_vis)
```
## See also
In the examples above we make heavy use of the `NLMR` package.
Both packages were developed together until we split them into pure landscape functionality and utility tools.
If you are interested in generating neutral landscapes via a multitude of available algorithms take a closer look at the [NLMR](https://github.com/ropensci/NLMR/) package.
## Meta
* Please [report any issues or bugs](https://github.com/ropensci/landscapetools/issues/new/).
* License: GPL3
* Get citation information for `landscapetools` in R doing `citation(package = 'landscapetools')`
* We are very open to contributions - if you are interested check [Contributing](CONTRIBUTING.md).
* Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
[![ropensci_footer](https://ropensci.org/public_images/github_footer.png)](http://ropensci.org)