-
Notifications
You must be signed in to change notification settings - Fork 4
/
temporal_subsets.Rmd
53 lines (44 loc) · 1.15 KB
/
temporal_subsets.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
---
title: "Temporal Subsets"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Temporal Subsets}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
```{r def_plotter}
library(sf)
plot_the_hex_grid <- function(occ_df){
hex_res <- 1 # hex_res 0 is too big to work, all others work
hex <- obisindicators::make_hex_res(hex_res)
# mapview::mapview(hex) # you can view the hex grid with h3 IDs
# === Then assign cell numbers to the occurrence data:
occ_df <- occ_df %>%
mutate(
cell = h3::geo_to_h3(
data.frame(decimalLatitude, decimalLongitude),
res = hex_res)) # calc indicators
idx <- calc_indicators(occ_df)
# Add cell geometries to the indicators table:
grid <- hex %>%
inner_join(
idx,
by = c("hexid" = "cell"))
# Plot map
gmap_indicator(grid, "es", label = "ES(50)")
}
```
```{r dgGEO_to_SEQNUM}
plot_the_hex_grid(occ_1960s)
plot_the_hex_grid(occ_1970s)
plot_the_hex_grid(occ_1980s)
plot_the_hex_grid(occ_1990s)
plot_the_hex_grid(occ_2000s)
plot_the_hex_grid(occ_2010s)
```