-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
163 lines (114 loc) · 7.74 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
---
output: github_document
---
<!-- 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 = "100%"
)
```
# dynamicSDM
<!-- badges: start -->
[![License](https://img.shields.io/badge/license-GPL%20%28%3E=%203%29-lightgrey.svg?style=flat)](http://www.gnu.org/licenses/gpl-3.0.html)
[![Codecov test coverage](https://codecov.io/gh/r-a-dobson/dynamicSDM/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-a-dobson/dynamicSDM?branch=main)
[![R-CMD-check](https://github.com/r-a-dobson/dynamicSDM/workflows/R-CMD-check/badge.svg)](https://github.com/r-a-dobson/dynamicSDM/actions)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7405906.svg)](https://doi.org/10.5281/zenodo.7405906)
[![Journal article](https://img.shields.io/badge/Published in-Methods in Ecology and Evolution-purple.svg)](https://doi.org/10.1111/2041-210X.14101)
[![CRAN status](https://www.r-pkg.org/badges/version/dynamicSDM)](https://CRAN.R-project.org/package=dynamicSDM)
<!-- badges: end -->
# Added features dynamicSDM v1.3
* Added function `extract_static_coords` for extracting spatially-buffered co-ordinate data from static datasets.
* Added arguments to `dynamic_proj_covariates()` for adding static rasters to covariates for each data (e.g. static elevation raster)
* Removed package dependency on `raster`, `sp`, `geodist` and `geosphere`.
* All functions are now `terra` and `sf` compatible.
* The package has since been published in the **Open Access journal "Methods in Ecology and Evolution"**
[*Dobson, R., Challinor, A.J., Cheke, R.A., Jennings, S., Willis, S.G. and Dallimer, M., 2023. dynamicSDM: An R package for species geographical distribution and abundance modelling at high spatiotemporal resolution. Methods in Ecology and Evolution, 14, 1190-1199.*](https://doi.org/10.1111/2041-210X.14101)
<a href='https://github.com/r-a-dobson/dynamicSDM'><img src="https://raw.githubusercontent.com/r-a-dobson/dynamicSDM/main/man/figures/MEE_title.png" align="centre" height="500" width="100%" /></a>
# Summary
Across ecological research fields, species distribution and abundance modelling (SDM) is a major tool for understanding the drivers and patterns of species occurrence. To advance our ability to model species inhabiting dynamic ecosystems worldwide, **dynamicSDM** facilitates the incorporation of explanatory variables that are dynamic in both space and time.
Our functions are:
* **user-friendly** - requiring only simple inputs and outputs;
* **highly flexible** - offering diverse and open arguments for targeting study specifics;
* **computer friendly** - utilising Google Earth Engine and Google Drive to minimise the computing power and storage demands associated with high spatiotemporal resolution modelling.
# Package structure
dynamicSDM functions are split into four key modelling stages: response data, explanatory variables, modelling relationships and dynamic projections. See the package manual [here](https://github.com/r-a-dobson/dynamicSDM/blob/main/man/figures/dynamicSDM_1.3.pdf) for more details on each function.
<a href='https://github.com/r-a-dobson/dynamicSDM'><img src="https://raw.githubusercontent.com/r-a-dobson/dynamicSDM/main/man/figures/Figure1.png" align="centre" height="300" width="100%" /></a>
### 1) Response data functions
Functions for preparing species distribution or abundance model input data for modelling with spatiotemporally dynamic explanatory variables.
* `convert_gbif()` Transform Global Biodiversity Information Facility occurrence records to `dynamicSDM` compatible.
* `spatiotemp_check()` Check species occurrence record formatting, completeness and validity.
* `spatiotemp_extent()` Filter species occurrence records by a given spatial and temporal extent.
* `spatiotemp_resolution()` Filter species occurrence records by given spatial and temporal resolution.
* `spatiotemp_bias()` Test for spatial and temporal bias in species occurrence records.
* `spatiotemp_thin()` Thin species occurrence records by spatial and temporal proximity.
* `spatiotemp_pseudoabs()` Generate pseudo-absence record coordinates and dates.
* `spatiotemp_weights()` Calculate sampling effort across spatial and temporal buffer from occurrence records.
### 2) Explanatory variable functions
Functions for extracting spatiotemporally dynamic explanatory variable data for species occurrence record co-ordinates and dates using Google Earth Engine.
* `extract_dynamic_coords()` Extract temporally dynamic explanatory variable data for occurrence records.
* `get_moving_window()` Generate a “moving window” matrix of optimal size for spatial buffering of explanatory variable data.
* `extract_buffered_coords()` Extract spatially buffered and temporally dynamic explanatory variable data for occurrence records.
* `extract_coords_combine()` Combine extracted explanatory variable data for occurrence records into single data frame for model fitting.
* `extract_static_coords` Extract spatially buffered data from static rasters for occurrence record co-ordinates (no temporal dimension).
### 3) Modelling relationship functions
Functions for generating species distribution or abundance models that account for spatial and temporal autocorrelation in dynamic explanatory variables.
* `spatiotemp_autocorr()` Test for spatial and temporal autocorrelation in species distribution model explanatory data.
* `spatiotemp_block()` Split occurrence records into spatial and temporal blocks for model fitting.
* `brt_fit()` Fit boosted regression tree models to species distribution or abundance data.
### 4) Dynamic projection functions
Functions for generating explanatory variable projection data frames at given spatiotemporal extent and resolution, and projecting species dynamic distribution and abundance patterns onto these.
* `dynamic_proj_dates()` Generate vector of dates for dynamic projections
* `extract_dynamic_raster()` Extract temporally dynamic rasters of explanatory variable data.
* `extract_buffered_raster()` Extract spatially buffered and temporally dynamic rasters of explanatory variable data.
* `dynamic_proj_covariates()` Combine explanatory variable rasters into a covariate data frame for each projection date.
* `dynamic_proj()` Project species distribution and abundance models onto dynamic environmental covariates.
* `dynamic_proj_GIF()` Create GIF of dynamic species distribution and abundance projections
# Installation
``` r
# Install using Github
install_github("r-a-dobson/dynamicSDM")
```
# Common installation errors
dynamicSDM depends on a range of spatial and graphic R packages, which may result in some persistent
errors on installation or running of certain functions.
If you encounter an error or bug when installing and using dynamicSDM, please post a comment
[here](https://github.com/r-a-dobson/dynamicSDM/issues) for guidance and support from us.
Below we have outlined common errors and typical solutions to try, depending on your operating
system
#### 1) Error with rgl
```{r,eval=F}
# Loading rgl's DLL failed. This build of rgl depends on XQuartz, which failed to load.
options(rgl.useNULL = TRUE)
library(rgl)
```
#### 2) Dependency package terra
On Homebrew (macOS) run:
```{Homebrew,eval=F}
brew install pkg-config
brew install gdal
```
On Linux run:
```{Linux,eval=F}
sudo apt-get install libgdal-dev libproj-dev libgeos-dev libudunits2-dev netcdf-bin
```
Then in R run:
```{r,eval=F}
install.packages("Rcpp")
install.packages('terra', repos='https://rspatial.r-universe.dev')
```
#### 3) Dependency package magick
On Homebrew (macOS) run:
```{Homebrew,eval=F}
brew install imagemagick@6
```
On Linux run:
```{Linux,eval=F}
sudo apt-get install -y libmagick++-dev
```
Then in R run:
```{r,eval=F}
install.packages("magick")
```