-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.Rmd
79 lines (67 loc) · 2.16 KB
/
index.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
---
title: "MBON Pole to Pole Project"
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = F, message = F, warning = F, fig.width=9.5, fig.height=12)
```
<br>
<br>
<font size="5">
Welcome! We are developing a Community of Practice across the Americas to assess marine biodiversity and ecosystem change using field and space observations.
<br>
<br>
Learn about ongoing biodiversity monitoring efforts contributing to the network by clicking markers on the map
```{r}
if (!require(librarian)){
install.packages("librarian")
library(librarian)
}
shelf(
glue, here, htmltools, leaflet, markdown, rnaturalearth, sf, tidyverse)
countries <- ne_countries(
scale = "small", type = "countries", returnclass = "sf",
continent= c("North America", "South America")) %>%
mutate(
mapcolor7 = as.factor(as.character(mapcolor7))) %>%
st_set_crs(4326)
sites_csv <- here("data/sites.csv")
sites <- read_csv(sites_csv, col_types=cols()) %>%
st_as_sf(coords = c("lon", "lat"), crs = 4326)
b <- sf::st_bbox(sites)
pal <- colorFactor("Set2", countries$mapcolor7)
```
```{r}
sites <- read_csv(sites_csv, col_types=cols()) %>%
st_as_sf(coords = c("lon", "lat"), crs = 4326) %>%
mutate(
md = glue("**{name}**<br>Org: {org}<br>Country: {str_to_upper(country)}<br>↪[ Visit](z_{id}.html)"),
html = map_chr(md, function(x) HTML(markdownToHTML(text=x, fragment.only=T))))
#View(sites)
leaflet(countries) %>%
addProviderTiles(
providers$Esri.OceanBasemap,
options = providerTileOptions(opacity = 0.5)) %>%
addPolygons(
stroke = FALSE, smoothFactor = 0.2, fillOpacity = 0.8,
fillColor = ~pal(mapcolor7),
label = ~admin) %>%
addMarkers(
data = sites,
popup = ~html, label = ~htmlEscape(name)) %>%
fitBounds(b[['xmin']], b[['ymin']], b[['xmax']], b[['ymax']])
```
```{r}
# poly_tbl <- c(40014, 40061, 40015, 40016, 40013, 40011, 40003, 21000, 20001)
#
# for (i in 1:length(poly_tbl))
# {
# area_code <- poly_tbl[i]
#
# ## Total
# total = occurrence(areaid = area_code, taxonid = c(51, 1806, 882, 3))
# csv <- here(glue("data/obis/obis_{area_code}.csv"))
# write.csv(total, file = csv)
# }
```