Birds in atmosphere

[This article was first published on, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

A photo of a gannet in the sky

Northern Gannet – Morus bassanus – CC-BY by caroline legg

Day 18 of 30DayMapChallenge: « Atmosphere » (previously).

Thanks to a post from @[email protected] I found a dataset (Warwick-Evans et al. 2017) that could (vaguely) relates to the theme of atmosphere.

It describes the trajectories of GPS tracked Northern Gannets (Morus bassanus L.) breeding on Alderney in the English Channel.




# GPS data
mb_file <- "northern_gannets-les_etacs-alderney.csv"

if (!file.exists(mb_file)) {
  download.file("", mb_file)

mb <- read_csv(mb_file) |> 

# countries from Natural Earth
countries <- ne_countries(scale = 10, returnclass = "sf") |> 

Build polylines from points

The do_union = FALSE is important to keep the points’ ordering in the line.

mb_traj <- mb |> 
  st_as_sf(coords = c("location_long", "location_lat"), crs = "EPSG:4326") |> 
  group_by(tag_local_identifier) |> 
  summarise(do_union = FALSE) |> 
  st_cast("LINESTRING") |> 


bbox <- st_bbox(mb_traj)
min_year <- year(min(mb$timestamp))
max_year <- year(max(mb$timestamp))

mb_traj |> 
  ggplot() +
  geom_sf(data = countries, color = NA) +
  geom_sf(aes(color = tag_local_identifier), alpha = 0.4) +
  geom_sf(data = countries, fill = NA) +
  annotation_scale(height = unit(1, "mm"), 
                   text_col = "darkgrey", line_col = "grey", 
                   bar_cols = c("white", "grey")) +
  coord_sf(xlim = bbox[c(1, 3)], ylim = bbox[c(2, 4)]) +
  labs(title = "Northern Gannets tracking study",
       subtitle = glue("Alderney, {min_year} - {max_year}"),
       caption = glue("{st_crs(mb_traj)$Name}
                    Data: DOI:10.5441/001/1.30r98tb3
                    Basemap: Natural Earth
           {Sys.Date()}")) +
  theme(legend.position = "none",
        plot.caption = element_text(size = 6), )

Map of Northern Gannets from Alderney

Figure 1: Northern Gannets from Alderney

Next stage would be to make an animation like @[email protected] post with {gganimate}…


Warwick-Evans, Victoria, Louise M. Soanes, Roland D. Gauvain, Phil W. Atkinson, John P. Y. Arnould, and Jon A. Green. 2017. “Data from: Changes in Behaviour Drive Inter‐annual Variability in the at‐sea Distribution of Northern Gannets.” Movebank Data Repository.
To leave a comment for the author, please follow the link and comment on their blog: offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)