library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.6.0
## ✔ ggplot2 3.5.2 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.2.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(leaflet)
library(sf)
## Linking to GEOS 3.13.0, GDAL 3.8.5, PROJ 9.5.1; sf_use_s2() is TRUE
library(rgbif)
#downloading cerulean warbler occurrence data
cewa <- occ_download_get(key="0016809-260226173443078", overwrite=TRUE) %>%
occ_download_import(cewa_download)
## Download file size: 24.19 MB
## On disk at /Users/emilywinslow/Desktop/EEB4100/Labs/0016809-260226173443078.zip
#this dataset is quite big, and it's making my map really laggy
cewa_subsample <- cewa[sample(nrow(cewa),50000),]
Cerulean warblers are Neotropical migrants; they spend their winters in northern South America and breed primarily in the northeastern United States. During migration, they consequently pass through much of Central America and the Southeastern US. Thus, I will split the data into three groups: breeding, migration, and wintering, based on location
#Cer
#I want to showcase occurrence by season (to show migration), so I want to try to make a column for "season" encompassing a few months each
cewa_breeding <- cewa_subsample %>% filter(decimalLatitude>35) #35 decimal degrees latitude is the southern border of Tennessee, which I am arbitrarily making my cutoff for CERW "breeding" range based on maps provided by Cornell Univeristy.
cewa_migration <- cewa_subsample %>% filter(decimalLatitude<35 & decimalLatitude>12.589364) #the lower cutoff represents the highest latitude in South America, roughly.
cewa_wintering <- cewa_subsample %>% filter(decimalLatitude<12.589364)
cewa$season <- ifelse (cewa$month %in% c('6','7','8'),
"SUMMER",
ifelse (cewa$month %in% c('9','10','11'),
"AUTUMN",
ifelse (cewa$month %in% c('12','1','2'),
"WINTER",
ifelse (cewa$month %in% c('3','4','5'),
"SPRING", NA))))
bogota_coords <- c(4.624335, -74.063644) #the capital of Colombia, where many CERW occur in winter.
atlanta_coords <- c(33.7501, -84.3885) #where many CERW sightings are clustered during migration.
nyc_coords <- c(40.7128, -74.0060) #many CERW detected in the area during the breeding season.
cerw_icon <- makeIcon(
iconUrl = "https://png.pngtree.com/png-vector/20251028/ourlarge/pngtree-cerulean-warbler-at-glacier-national-park-spring-waterfall-and-mountains-png-image_17840411.webp",
iconWidth = 95, iconHeight = 95,
iconAnchorX = 22, iconAnchorY = 94
)
#making a color palette for season
library(RColorBrewer)
library(terra)
## terra 1.8.60
##
## Attaching package: 'terra'
## The following object is masked from 'package:tidyr':
##
## extract
## The following object is masked from 'package:knitr':
##
## spin
library(leaflet.extras2)
#mapping
leaflet() %>%
addTiles() %>%
addOpenweatherTiles(apikey = "1c01588b900a0407c9bf53faa4553355", layers="temperature",
group="Temperature", opacity = .75) %>%
addProviderTiles("OpenTopoMap") %>%
addCircleMarkers(data=cewa_breeding,
~decimalLongitude, ~decimalLatitude,
radius=1, color="#fb8072",
group="Breeding Range") %>%
addCircleMarkers(data=cewa_migration,
~decimalLongitude, ~decimalLatitude,
radius=1, color="#8f88bf",
group= "Migration Range") %>%
addCircleMarkers(data=cewa_wintering,
~decimalLongitude, ~decimalLatitude,
radius=1, color="#478ebf",
group="Wintering Range") %>%
addMarkers(lng=nyc_coords[2], lat = nyc_coords[1], label = "New York City", icon = cerw_icon, labelOptions = labelOptions(noHide = TRUE)) %>%
addMarkers(lng=atlanta_coords[2], lat = atlanta_coords[1], label = "Atlanta", icon = cerw_icon, labelOptions = labelOptions(noHide = TRUE)) %>%
addMarkers(lng=bogota_coords[2], lat = bogota_coords[1], label = "Bogota", icon = cerw_icon, labelOptions = labelOptions(noHide = TRUE)) %>%
addLayersControl(overlayGroups = c("Breeding Range", "Migration Range", "Wintering Range", "Temperature"),
options = layersControlOptions(collapsed = FALSE)) %>%
addLegend(position="bottomleft",
title = "Elevation",
pal = colorNumeric(palette = c("lightgreen", "green", "darkgreen", "yellow", "orange", "red"), domain = c(0, 2000)),
values = c(0, 2000),
labels = c("0-200m", "201-400m", "401-600m", "601-800m", "801-1000m", "1001-2000m"),opacity = 1) %>%
addLegend(position="topright",
title="Seasonal Range",
colors=c("#fb8072", "#8f88bf", "#478ebf"),
labels=c("Cerulean Warbler Breeding Range", "Cerulean Warbler Migration Range", "Cerulean Warbler Wintering Range"),
opacity=1)
This map depicts Cerulean warbler (Setophaga cerulea) migration. Cerulean warblers are Neotropical migrants, and their range can be split into three general phases: breeding (summer), migration (autumn and spring), and wintering. Thus, I color-coded the occurrence data to reflect these three ranges roughly as they are depicted by Cornell University (https://www.allaboutbirds.org/guide/Cerulean_Warbler/maps-range). To improve readability, I tried to code the ranges with colors that made sense (e.g., the warmest hue for the summer breeding range, and the coolest hue for the wintering range). I added elevation and temperature data using provider tiles, which are intuitively color coded as well. I also ensured that layers could be toggled on/off so that different data could be observed individually. When choosing which cities to represent on the map, I focused on choosing one city in each part of the bird’s range that had a high volume of observations nearby.