library(knitr) knitr::opts_chunk$set(collapse = TRUE, message = FALSE, warning = FALSE, eval = FALSE, comment = "#>" )
On this website, you can find a ggOceanMaps poster presented at the Sharks International Conference 2022 in Valencia, Spain. This site also contains references in the poster and code used to make the figures and download the example datasets. Make sure to visit the front page to learn how to install ggOceanMaps, the user manual showing how to use the package and the function reference to see practical examples.
Click the picture to download a pdf of the poster with embedded links.
The numbered references in the poster:
Script to download data used in the poster:
# GBIF data library(tidyverse) library(ggOceanMaps) library(rgbif) ## Donwload example from: https://docs.ropensci.org/rgbif species <- c(BlueShark = "Prionace glauca", BaskingShark = "Cetorhinus maximus") GBIF <- lapply(seq_along(species), function(i) { message(species[i], "...") key <- rgbif::name_backbone(name = species[[i]])[c("canonicalName", "speciesKey")] rgbif::occ_search( taxonKey = key$speciesKey, return = "data", limit = 4e5, geometry = c(-20, 30, 20, 76)) }) GBIF_blue <- GBIF[[1]]$data %>% rename("lat" = "decimalLatitude", "lon" = "decimalLongitude") %>% dplyr::select(lon, lat) %>% transform_coord(bind = TRUE) %>% dist2land() GBIF_basking <- GBIF[[2]]$data %>% rename("lat" = "decimalLatitude", "lon" = "decimalLongitude") %>% dplyr::select(lon, lat) %>% transform_coord(bind = TRUE) %>% dist2land() # Dugnad for havet data DugnadForHavet <- read_delim( "data/DFH_basking_shark.csv", # from: https://dugnadforhavet.no/dataportal delim = ";") %>% arrange(amount) %>% filter(!is.na(longitude), !is.na(latitude)) %>% transform_coord(bind = TRUE) %>% dist2land() %>% as_tibble()
Note that the correct way to do the download would be something like shown under and on the website, but I did not have a user name when making the poster, and there were <7000 records of these shark species in the Northeast Atlantic. Hence the 100k limit was not an issue. Citing correct data sources, however, is an issue and if you are planning to use the data in more serious applications than posters, make sure to find the correct DOI using occ_download()
or the web portal.
keys <- species %>% name_backbone_checklist() %>% # match to backbone filter(!matchType == "NONE") %>% # get matched names pull(usageKey) occ_download( pred_in("taxonKey",key$speciesKey), pred("hasCoordinate", TRUE), pred("hasGeospatialIssue", FALSE), pred_within("POLYGON ((-20 30, 20 30, 20 80, -20 80, -20 30))") )
## Background map a1_h <- 841-1 # Poster height without margins (A1) a1_w <- 594-1.2 # Poster width without margins (A1) asp <- a1_h/a1_w # To get correct size because aspect ratio is fixed lon_min <- -1.5e6 # Projected coordinates lon_max <- 2e6 lat_min <- -6.5e6 lat_max <- lat_min + asp*diff(c(lon_min, lon_max)) bm <- basemap( c(lon_min, lon_max, lat_min, lat_max), shapefiles = "Arctic", lon.interval = 10, bathymetry = TRUE, legends = FALSE) + theme(axis.title = element_blank()) + geom_spatial_point( data = DugnadForHavet, aes(x = longitude, y = latitude, size = amount), color = "#FF5F68", alpha = 0.8 ) + geom_density_2d( data = DugnadForHavet, contour_var = "ndensity", size = LS(1), aes(x = lon.proj, y = lat.proj, color = after_stat(level)) ) + geom_spatial_point( data = GBIF_blue %>% filter(ldist > 0), aes(x = lon, y = lat), color = "#FFC95B", alpha = 0.8, size = 3 ) + geom_density_2d( data = GBIF_blue, contour_var = "ndensity", size = LS(1), aes(x = lon.proj, y = lat.proj, color = after_stat(level)) ) + scale_size(range = c(1,10)) + scale_color_distiller(palette = "Spectral", na.value = NA) + theme(legend.position = "none") ## Distance to land DugnadForHavet %>% mutate(species = "Basking shark") %>% dplyr::select(species, ldist) %>% bind_rows( GBIF_basking %>% mutate(species = "Basking shark") %>% dplyr::select(species, ldist), GBIF_blue %>% mutate(species = "Blue shark") %>% dplyr::select(species, ldist) ) %>% ggplot(aes(x = ldist, after_stat(ndensity), color = species)) + geom_freqpoly(size = LS(5)) + scale_color_manual(values = c("#FF5F68", "#FFC95B")) + labs(x = "Standardized density", y = "Distance from land (km)", color = "Species") + coord_cartesian(expand = FALSE, ylim = c(0,1.05), xlim = c(0,500)) + theme_classic() + theme(legend.position = c(0.7,0.9))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.