Download right whale dataset

from MarineCadastre.

library(here)
library(fs)
library(utils)

url <- "http://seamap.env.duke.edu/models/Duke-EC-GOM-2015/results/EC_North_Atlantic_right_whale.zip"

dir_data  <- here("data")
zip       <- file.path(dir_data, basename(url))
dir_unzip <- path(dir_data, path_ext_remove(basename(zip)))

if (!dir_exists(dir_unzip)){
  dir_create(dir_unzip)
  download.file(url, zip)
  unzip(zip, exdir = dir_unzip)
  file_delete(zip)
}

Map of right whale data

library(raster)
library(leaflet)

rwhale_img <- "data/EC_North_Atlantic_right_whale/EC_North_Atlantic_right_whale_month05_abundance.img"

rwhale <- raster(rwhale_img)

col_pal <- colorNumeric(
  "Spectral", values(rwhale), reverse = T, na.color = "transparent")

leaflet(
  options = leafletOptions(attributionControl = F)) %>%
  addProviderTiles(providers$Esri.OceanBasemap) %>%
  addRasterImage(
    rwhale, colors = col_pal, opacity = 0.7) %>% 
  addLegend(
    pal = col_pal, values = values(rwhale), 
    title = "right whales")

Map of polygon

Extraction of data

vals <- extract(rwhale, ply)[[1]]

hist(vals)