American Goldfinches

Goldfinches are migratory birds that are known for their gold color. I have a soft spot for them because despite how common they are, I’ve never seen/identified one. I’ve seen cardinals, blue-jays, and a number of other brightly-colored native birds, but not a bright gold goldfinch!

Gathering Data from GBIF:

I didn’t include Nov or Dec stats, but the number of observations was so large I was basically only getting one month in these datasets either way

Goldfinch_Summer <- occ_search(
  scientificName = "Spinus tristis",
  month = '5,10',
  hasCoordinate = TRUE,
  limit = 500
)$data

Goldfinch_Winter <- occ_search(
  scientificName = "Spinus tristis",
  month = '1,4',
  hasCoordinate = TRUE,
  limit = 500
)$data

as well as some temp data I subsetted from NOAA

temp <- rast("../subset.nc")

Displaying the Data:

Map_Gold_Unpolished <- leaflet() %>% 
  setView(lng = -79, lat = 37.8, zoom = 5) %>% 
  addTiles() %>%
  addProviderTiles(providers$Esri.NatGeoWorldMap) %>% 
  addProviderTiles(providers$OpenTopoMap) %>%
  addRasterImage(temp, colors = colorNumeric(palette = c("#0571b0","#67a9cf","#f7f7f7","#ef8a62","#ca0020"),
                                             domain = c(260,325),na.color = NA), 
                 opacity = 0.9, group = "Temperature") %>%
  addCircleMarkers(data = Goldfinch_Summer, 
                   ~decimalLongitude, ~decimalLatitude, 
                   color = "#EBCB31", fillOpacity = 1, radius = 2, 
                   popup = ~paste(name, ":", scientificName, "<br>", eventDate),
                   group = "Summer Goldfinch Observations") %>%
  addCircleMarkers(data = Goldfinch_Winter,
                   ~decimalLongitude, ~decimalLatitude, 
                   color = "#1D3678", fillOpacity = 1, radius = 2, 
                   popup = ~paste(name, ":", scientificName, "<br>", eventDate),
                   group = "Winter Goldfinch Observations")

Map_Gold_Unpolished

Large Cities

I’m choosing NY, Houston, and Toronto, they all have millions of residents. Just add their latitude/longitude/name to different vectors so a single add marker can handle them all.

Lats <- c(40.7128, 43.6548, 29.7601)
Lons <- c(-74.0060, -79.3884, -95.3701)
CityLabels <- c("New York City", "Toronto", "Houston")

Map_Gold_Cities <- leaflet() %>% 
  setView(lng = -79, lat = 37.8, zoom = 5) %>% 
  addTiles() %>%
  addProviderTiles(providers$Esri.NatGeoWorldMap) %>% 
  addProviderTiles(providers$OpenTopoMap) %>%
  addRasterImage(temp, colors = colorNumeric(palette = c("#0571b0","#67a9cf","#f7f7f7","#ef8a62","#ca0020"),
                                             domain = c(260,325),na.color = NA), 
                 opacity = 0.9, group = "Temperature") %>%
  addCircleMarkers(data = Goldfinch_Summer, 
                   ~decimalLongitude, ~decimalLatitude, 
                   color = "#EBCB31", fillOpacity = 1, radius = 2, 
                   popup = ~paste(name, ":", scientificName, "<br>", eventDate),
                   group = "Summer Goldfinch Observations") %>%
  addCircleMarkers(data = Goldfinch_Winter,
                   ~decimalLongitude, ~decimalLatitude, 
                   color = "#1D3678", fillOpacity = 1, radius = 2, 
                   popup = ~paste(name, ":", scientificName, "<br>", eventDate),
                   group = "Winter Goldfinch Observations") %>%
  addMarkers(lng = Lons, lat = Lats, label = CityLabels)

Map_Gold_Cities

Labels/Legend

added the elevation scale, toggles for winter/summer observations and a key to tell the colors apart, as well as a toggle for the temp data.

Map_Gold_Done <- leaflet() %>% 
  setView(lng = -79, lat = 37.8, zoom = 5) %>% 
  addTiles() %>%
  addProviderTiles(providers$Esri.NatGeoWorldMap) %>% 
  addProviderTiles(providers$OpenTopoMap) %>%
  addRasterImage(temp, colors = colorNumeric(palette = c("#0571b0","#67a9cf","#f7f7f7","#ef8a62","#ca0020"),
                                             domain = c(260,325),na.color = NA), 
                 opacity = 0.9, group = "Temperature") %>%
  addCircleMarkers(data = Goldfinch_Summer, 
                   ~decimalLongitude, ~decimalLatitude, 
                   color = "#EBCB31", fillOpacity = 1, radius = 2, 
                   popup = ~paste(name, ":", scientificName, "<br>", eventDate),
                   group = "Summer Goldfinch Observations") %>%
  addCircleMarkers(data = Goldfinch_Winter,
                   ~decimalLongitude, ~decimalLatitude, 
                   color = "#1D3678", fillOpacity = 1, radius = 2, 
                   popup = ~paste(name, ":", scientificName, "<br>", eventDate),
                   group = "Winter Goldfinch Observations") %>%
  addMarkers(lng = Lons, lat = Lats, label = CityLabels)%>%
  addLayersControl(
    overlayGroups = c("Summer Goldfinch Observations", "Winter Goldfinch Observations","Temperature"),
    options = layersControlOptions(collapsed = FALSE)) %>%
  addLegend(position = "bottomright", 
            colors = c("#EBCB31", "#1D3678"), 
            labels = c("Summer Goldfinch Observations", "Winter Goldfinch Observations"), 
            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)

Map_Gold_Done