
Obtain list of contacts from several DEIMS ID's (in csv file)
Alessandro Oggioni, Paolo Tagliolato
Source:vignettes/multi_sites_contacts.Rmd
multi_sites_contacts.Rmd
Starting from the DEIMS-SDR “Advanced Search - Sites” interface, users can download a csv file of the sites. Some filters can be used for selecting sites based on countries, projects, Biome, etc. The list of selected sites can be downloaded in csv format.
This vignette begins with such a csv file, and shows how to:
- Obtain contacts details, and spatial info for all sites (limited to 7 sites)
- Display in a table
- Prepare of map of those sites
List of the contacts
library(ReLTER)
library(dplyr)
library(sf)
library(leaflet)
site_results <- read.csv("./data/site_contacts_data.csv", sep = ";") %>%
as_tibble() %>%
mutate(url = paste0("https://deims.org/", DEIMS.ID)) %>%
top_n(10) %>%
unique()
# contacts <- site_results$url %>%
# purrr::map_dfr(.f = function(x) {
# x %>% ReLTER::get_site_info(category = "Contacts") %>%
# dplyr::select(title, uri, siteManager, geoCoord) %>%
# tidyr::unnest()
# }) %>%
# dplyr::mutate(
# site = paste0("[", title, "](", uri, ")"),
# contact = paste0("[", name, "](mailto:", email, ")")
# ) %>%
# unique()
#})
contacts <- lapply(site_results$url, function(u) {
contact_info <- ReLTER::get_site_info(u, c("Contacts", "Boundary"))
sm <- as.data.frame(contact_info$siteManager)
cntt <- data.frame(site = paste0("[", contact_info$title, "](", contact_info$uri, ")"),
contact = paste0("[", sm$name, "](mailto:", sm$email, ")"),
geoCoord = contact_info$geoCoord)
return(cntt)
})
contacts <- do.call(rbind, contacts)
# Contacts table
knitr::kable(contacts[, c("site", "contact")],
#(contacts %>% dplyr::select(site, contact)),
caption = "List of the contacts",
booktabs = TRUE, longtable = TRUE
)
Map of the sites
site_results_geo <- st_as_sf(
contacts,
wkt = "geoCoord"
)
listItaSitesMap <- leaflet(site_results_geo) %>%
addTiles() %>%
addCircleMarkers(
data = site_results_geo,
radius = 3,
weight = 2,
opacity = 0.5,
fill = TRUE,
fillOpacity = 0.2,
popup = paste0(
'<b>eLTER site: </b><br><a href="',
site_results_geo$uri, '">', site_results_geo$title, '</a><br>',
'<b>Contact:</b> <br><a href="mailto:', site_results_geo$email, '">',
site_results_geo$name, '</a>'
)
)
listItaSitesMap
## Error in path.expand(path): invalid 'path' argument