-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
120 lines (93 loc) · 4.12 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
---
output:
rmarkdown::github_document:
html_preview: no
---
<!--- README.md is generated from README.Rmd. Please edit that file -->
# Habitat classification data from Lumbierres *et al.* 2021
[![lifecycle](https://img.shields.io/badge/Lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![DOI](https://img.shields.io/badge/DOI-10.5281/zenodo.6622059-blue.svg)](https://doi.org/10.5281/zenodo.6622059)
```{r, include = FALSE}
knitr::opts_chunk$set(fig.path = "figures/README-", fig.align = "center")
```
This repository contains code to generate global habitat classification data (based on Lumbierres *et al.* 2021). Specifically, source data are downloaded and then projected to the World Behrmann coordinate reference system using (100 m resolution; [ESRI:4326 coordinate reference system](https://epsg.io/54017)). A processed version of the data can be downloaded from the [Zenodo Digital Repository](https://doi.org/10.5281/zenodo.6622059). **All credit should go to Lumbierres *et al.* (2021), please cite their work if you use this dataset.**
```{r "preliminary_processing", echo = FALSE, message = FALSE, warning = FALSE}
# load packages
library(dplyr)
library(terra)
library(ggplot2)
# find file paths
data_path <- dir("results", "^.*tif$", full.names = TRUE)
# load raster
data_raster <- terra::rast(data_path)
# extract data to plot (note that we spatially sample data to reduce run time)
plot_data <-
data_raster %>%
terra::spatSample(size = 400000, method = "regular", as.raster = TRUE) %>%
terra::as.data.frame(xy = TRUE) %>%
dplyr::rename(value = 3) %>%
dplyr::mutate(title = "Habitat classification") %>%
dplyr::mutate(subtitle = basename(data_path)) %>%
dplyr::mutate(value = as.character(value))
# create an underlying map
p <-
ggplot() +
coord_fixed(expand = FALSE) +
geom_tile(
data = plot_data,
mapping = aes(x = x, y = y, fill = value)
) +
facet_wrap(~ title + subtitle) +
theme(
legend.pos = "hide",
axis.ticks = element_blank(),
axis.text = element_blank(),
axis.title = element_blank(),
axis.line = element_blank(),
axis.ticks.length = unit(0, "null"),
axis.ticks.margin = unit(0, "null"),
panel.border = element_blank(),
panel.background = element_blank(),
panel.grid = element_blank(),
legend.text = element_text(size = 8),
legend.margin = unit(0, "null"),
plot.margin = unit(c(0.001, 0.001, 0.001, 0.01), "pt"),
strip.background = ggplot2::element_rect(color = "black", fill = "black"),
strip.text = ggplot2::element_text(color = "white")
)
```
```{r "map", echo = FALSE, message = FALSE, warning = FALSE, fig.height = 2.3, fig.width = 5.0, dpi = 300}
# render plot
print(p)
```
## Metadata
The habitat classification data are stored in a raster (GeoTIFF) file. The file name contains the version number of the original datasets (i.e., per the digital object identifier). The latest version of the file is ``r basename(data_path)``.
The metadata for the ``r basename(data_path)`` raster file is shown below.
```{r, echo = FALSE, comment = NA}
withr::with_dir("results", {
cat(
system(paste("gdalinfo", basename(data_path)), intern = TRUE),
sep = "\n"
)
})
```
## Usage
You can run the code to produce the dataset using the system command `make clean all`. After processing has successfully completed, the code will produce two raster (GeoTIFF) files in the `results` directory.
## Software requirements
Operating system
* Ubuntu (21.10) (300 Gb disk space available)
Software
* GNU make (version 4.1)
* GDAL (version 3.2.2)
* R (version 4.1.1)
System packages
* `gdal-bin`
* `libudunits2-dev`
* `libgdal-dev`
* `libgeos-dev`
* `libproj-dev`
* `libxml2-dev`
* `libssl-dev`
## Citation
This dataset was derived from Lumbierres *et al.* (2021). If you use this dataset, you should cite their work - they deserve all the credit!
> Lumbierres M, Dahal PR, Di Marco M, Butchart SHM, Donald PF, and Rondinini C (2021) Translating habitat class to land cover to map area of habitat of terrestrial vertebrates. *Conservation Biology*, **In press**, DOI:10.1111/cobi.13851. Available at https://doi.org/10.1111/cobi.13851.