-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
122 lines (82 loc) · 4.92 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
---
output: github_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "90%"
)
library(saltbush)
```
<!-- badges: start -->
[![](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![R-CMD-check](https://github.com/traitecoevo/saltbush/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/traitecoevo/saltbush/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/traitecoevo/saltbush/graph/badge.svg)](https://app.codecov.io/gh/traitecoevo/saltbush)
<!-- badges: end -->
# saltbush <img src="man/figures/saltbush_hex.png" align="right" width="200"/>
*saltbush* processes drone imagery to calculate spectral diversity values as part of the assessment of the 'spectral variability hypothesis' or the 'spectral-biodiversity relationship'. This was specifically implemented to connect *from-the-sky* diversity with *on-the-ground* diversity as measured in the AusPlots project. There are also functions to calculate on-the-ground diversity built on the [ausplotsR](https://github.com/ternaustralia/ausplotsR) and [vegan](https://github.com/vegandevs/vegan) packages. The statistical methods for connecting diversity sampled on the ground to diversity sampled from the sky are still developing. This package is aimed at making from-the-sky diversity methods development easier for researchers across the world.
Specifically we have used this package in a test in the Australian arid zone. The results suggest that some of the methods below perform much better than others. See our paper *Placeholder to link to the preprint once that's posted.*
## Installation
```{r install, eval= FALSE}
install.packages("remotes")
remotes::install_github("traitecoevo/saltbush")
```
## Usage
1. **Direct the package to the input files** in this case we use a drone image from Fowlers Gap, NSW, Australia
The example data in this case is 5 bands sampled from a drone
```{r, message=FALSE, results='hide'}
create_multiband_image("inst/extdata/create_multiband_image/",
c('blue', 'green', 'red', 'red_edge', 'nir'),
output_dir = tempdir(),
make_plot = TRUE, return_raster = TRUE)
```
The resulting multiband image can be combined with an area of interest shapefile:
```{r}
raster_files <- list.files("inst/extdata/example",
pattern = '.tif$', full.names = TRUE)
aoi_files <- list.files("inst/extdata/aoi",
pattern = 'NSABHC0009_aoi.shp$', full.names = TRUE)
```
2. **Extract pixel values** from the area of interest in the image
```{r}
pixel_values <- extract_pixel_values(raster_files,
aoi_files)
head(pixel_values)
```
3. **Calculate spectral metrics**
```{r}
metrics <- calculate_spectral_metrics(pixel_values,
wavelengths = colnames(pixel_values[, 2:6]),
masked = F,
rarefaction = F)
head(metrics)
```
+ co-efficient of variance (CV)
+ spectral variance (SV)
+ convex hull volume (CHV)
For a full discussion of these metrics see the manuscript
4. **Download plot data** from AusPlots. The `veg.PI` part extracts the point intercept data from the AusPlots data structure. In this case we use the same AusplotID as in the drone images above. This gets us data for two on-the-ground sampling visits to one particular AusPlot where we happen to have drone imagery.
```{r, message=FALSE}
my.data <- ausplotsR::get_ausplots(my.Plot_IDs=c("NSABHC0009"), veg.PI=TRUE)
my.data$site.info$visit_date
```
5. **Calculate on-the-ground diversity** from the point intercepts using different diversity metrics. The output is a list which includes taxonomic metrics, and also community matrices for checks. Not that this takes the `PI` part of the AusPlot object which stands for point-intercept. For a general function to calculate on-the-ground diversity, see [the diversity function from the vegan package](https://rdrr.io/cran/vegan/man/diversity.html).
```{r}
field_diversity <- calculate_field_diversity(my.data$veg.PI)
field_diversity$taxonomic_diversity
```
2012 was wetter than 2016 and there are a number of rain ephemeral species at this site so the higher species richness makes sense.
The calculated taxonomic diversity metrics are:
+ species richness
+ shannon's diversity index
+ simpson's diversity index
+ pielou's evenness
+ exponential shannon's index
+ inverse simpson's index
6. **Compare on-the-ground and from-the-sky diversity**
High-resolution drone images are very large, and the example data included with the package on github are too small to do this meaningfully. We recommend doing this locally following the above steps.