Is a cute bird that my roommate studies. Colonies move to the north coast of South America and Trinidad during their non-breeding season. Leaves North America entirely in winter, to winter in Caribbean and along northern coast of South America. One of the largest colonies of Sterna dougallii is at the Great Gull island- where my roommate does field work every summer. Loading files..
stern_gbif <- occ_download_get(key = "0026924-240216155721649", overwrite = TRUE) %>%
occ_download_import(stern_gbif_download, na.strings = c("", NA))
## Download file size: 0.06 MB
## On disk at /Users/vidya/Desktop/EEB4100/Lab solutions/0026924-240216155721649.zip
## OR i could do this- after looking at Jill's script!
stern_observations <- occ_search(
scientificName = "Sterna dougallii",
country = "US",
hasCoordinate = TRUE,
limit = 2000
)$data
Splitting migration patterns. Roseate terns are split between Great Gull Island and the Carribean region.
stern_obv_summer <- stern_gbif %>% filter(countryCode=="US")
stern_obv_winter<- stern_gbif %>% filter(countryCode %in% c("BS", "DM", "JM"))
#Visualizing Now a map that ties migration patterns, elevation, and temperature.
library(raster)
## Loading required package: sp
##
## Attaching package: 'raster'
## The following object is masked from 'package:dplyr':
##
## select
#Loading temp raster file, and downsampling because it's big
temperature_raster <- raster("temperature/temperature.tif")
downsampled_temp <- aggregate(temperature_raster, fact = 4)
map <- leaflet() %>% setView(lng = -79, lat = 37.8, zoom = 5) %>% addTiles() %>%
addProviderTiles(providers$Esri.NatGeoWorldMap) %>%
addProviderTiles(providers$OpenTopoMap) %>%
addCircleMarkers(data = stern_obv_summer,
~decimalLongitude, ~decimalLatitude,
color = "#FFB6C1", fillOpacity = 1, radius = 3,
popup = ~paste(scientificName, "<br>", eventDate),
group = "Sterna dougallii observations") %>%
addCircleMarkers(data = stern_obv_winter,
~decimalLongitude, ~decimalLatitude,
color = "blue", fillOpacity = 1, radius = 3,
popup = ~paste(scientificName, "<br>", eventDate),
group = "Sterna dougallii winter observations") %>%
addRasterImage(downsampled_temp, colors = "cyan", opacity = 0.7, group = "Temperature") %>%
addLayersControl(
overlayGroups = c("Sterna dougallii observations", "Sterna dougallii winter observations", "Temperature"),
options = layersControlOptions(collapsed = FALSE)) %>%
addLegend(position = "bottomright",
colors = c("#FFB6C1", "blue", "cyan"),
labels = c("Sterna dougallii observations", "Sterna dougallii winter observations", "Temperature"),
opacity = 1) %>%
addLegend("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)
## Warning in validateCoords(lng, lat, funcName): Data contains 22 rows with
## either missing or invalid lat/lon values and will be ignored
## Warning in validateCoords(lng, lat, funcName): Data contains 282 rows with
## either missing or invalid lat/lon values and will be ignored
map
I’m choosing New York City, Santo Domingo, and Nassau
# Latitude and Longitude for New York City
nyc_coords <- c(40.7128, -74.0060)
# Latitude and Longitude for Santo Domingo
santo_domingo_coords <- c(18.4861, -69.9312)
# Latitude and Longitude for Nassau
nassau_coords <- c(25.0343, -77.3963)
map <- leaflet() %>% setView(lng = -79, lat = 37.8, zoom = 5) %>% addTiles() %>%
addProviderTiles(providers$Esri.NatGeoWorldMap) %>%
addProviderTiles(providers$OpenTopoMap) %>%
addCircleMarkers(data = stern_obv_summer,
~decimalLongitude, ~decimalLatitude,
color = "#FFB6C1", fillOpacity = 1, radius = 3,
popup = ~paste(scientificName, "<br>", eventDate),
group = "Sterna dougallii observations") %>%
addCircleMarkers(data = stern_obv_winter,
~decimalLongitude, ~decimalLatitude,
color = "blue", fillOpacity = 1, radius = 3,
popup = ~paste(scientificName, "<br>", eventDate),
group = "Sterna dougallii winter observations") %>%
addRasterImage(downsampled_temp, colors = "cyan", opacity = 0.7, group = "Temperature") %>%
addLayersControl(
overlayGroups = c("Sterna dougallii observations", "Sterna dougallii winter observations", "Temperature"),
options = layersControlOptions(collapsed = FALSE)) %>%
addLegend(position = "bottomright",
colors = c("#FFB6C1", "blue", "cyan"),
labels = c("Sterna dougallii observations", "Sterna dougallii winter observations", "Temperature"),
opacity = 1) %>%
addLegend("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) %>%
addMarkers(lng = nyc_coords[2], lat = nyc_coords[1], label = "New York City", labelOptions = labelOptions(noHide = TRUE)) %>%
addMarkers(lng = santo_domingo_coords[2], lat = santo_domingo_coords[1], label = "Santo Domingo", labelOptions = labelOptions(noHide = TRUE)) %>%
addMarkers(lng = nassau_coords[2], lat = nassau_coords[1], label = "Nassau", labelOptions = labelOptions(noHide = TRUE))
## Warning in validateCoords(lng, lat, funcName): Data contains 22 rows with
## either missing or invalid lat/lon values and will be ignored
## Warning in validateCoords(lng, lat, funcName): Data contains 282 rows with
## either missing or invalid lat/lon values and will be ignored
map
#Putting custom icon on map
huskyIcon <- makeIcon(
iconUrl = "uconn.jpeg",
iconWidth = 45,
iconHeight = 45,
iconAnchorX = 25,
iconAnchorY = 25)
birdpoopIcon <- makeIcon(
iconUrl = "bird_poop.png",
iconWidth = 45,
iconHeight = 45,
iconAnchorX = 25,
iconAnchorY = 25)
My roommate kept complaining that the roseate turns kept pecking at her and pooping on her (poor roomie), I want to label Great Gull to recognize the evil nature of roseate turns. Also a Husky, cause we’re Huskies.
map <- leaflet() %>% setView(lng = -79, lat = 37.8, zoom = 5) %>% addTiles() %>%
addProviderTiles(providers$Esri.NatGeoWorldMap) %>%
addProviderTiles(providers$OpenTopoMap) %>%
addCircleMarkers(data = stern_obv_summer,
~decimalLongitude, ~decimalLatitude,
color = "#FFB6C1", fillOpacity = 1, radius = 3,
popup = ~paste(scientificName, "<br>", eventDate),
group = "Sterna dougallii observations") %>%
addCircleMarkers(data = stern_obv_winter,
~decimalLongitude, ~decimalLatitude,
color = "blue", fillOpacity = 1, radius = 3,
popup = ~paste(scientificName, "<br>", eventDate),
group = "Sterna dougallii winter observations") %>%
addRasterImage(downsampled_temp, colors = "cyan", opacity = 0.7, group = "Temperature") %>%
addLayersControl(
overlayGroups = c("Sterna dougallii observations", "Sterna dougallii winter observations", "Temperature"),
options = layersControlOptions(collapsed = FALSE)) %>%
addLegend(position = "bottomright",
colors = c("#FFB6C1", "blue", "cyan"),
labels = c("Sterna dougallii observations", "Sterna dougallii winter observations", "Temperature"),
opacity = 1) %>%
addLegend("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) %>%
addMarkers(lng = nyc_coords[2], lat = nyc_coords[1], label = "New York City", labelOptions = labelOptions(noHide = TRUE)) %>%
addMarkers(lng = santo_domingo_coords[2], lat = santo_domingo_coords[1], label = "Santo Domingo", labelOptions = labelOptions(noHide = TRUE)) %>%
addMarkers(lng = nassau_coords[2], lat = nassau_coords[1], label = "Nassau", labelOptions = labelOptions(noHide = TRUE)) %>%
addMarkers(lng = -72.12, lat = 41.2, label = "Great Gull Island", labelOptions = labelOptions(noHide = TRUE), icon = birdpoopIcon) %>%
addMarkers(lng = -72.24, lat = 41.80, label = "Storrs CT", labelOptions = labelOptions(noHide = TRUE), icon = huskyIcon)
## Warning in validateCoords(lng, lat, funcName): Data contains 22 rows with
## either missing or invalid lat/lon values and will be ignored
## Warning in validateCoords(lng, lat, funcName): Data contains 282 rows with
## either missing or invalid lat/lon values and will be ignored
map