16 Read and use
16.1 Read Geolocator Data Package
A cool feature of Zenodo is that you can load the data directly without downloading the files!
pkg <- read_gldp("https://zenodo.org/records/14099115/files/datapackage.json")
Alternatively, it’s possible to load the file from a local directory:
16.2 Analyse data with GeoPressureTemplate
If this data package has not yet been analysed with GeoPressureR, you can create a GeoPressureTemplate folder from the data package using the following code. Note that this code will open a new RStudio session.
dest_dir <- tempfile() #
project_dir <- write_geopressuretemplate(pkg, destdir = dest_dir, overwrite = TRUE)
! Created directory: /var/folders/cm/dh8lmmxn3b5bcb2_gbz16ycm0000gn/T//RtmpRy0SHX/filefd9150b0fd0d
✔ Setting active project to
"/private/var/folders/cm/dh8lmmxn3b5bcb2_gbz16ycm0000gn/T/RtmpRy0SHX/filefd9150b0fd0d/woodlandkingfisher".
✔ Writing 'LICENSE.md'.
⠙ 4/5 ETA: 1s |
Note
Make sure all the steps to make yourself at home have been performed.
You’re now ready to analyse your data according to the GeoPressureTemplate instructions!
16.3 Use analysed data
If the datapackage you want to use has already been analysed, you can retrieve all the resources of the datapackage:
# List available resources
print(pkg)
A GeoLocator Data Package with 8 resourcess:
• tags
• observations
• measurements
• twilights
• staps
• paths
• edges
• pressurepaths
Use `unclass()` to print the Data Package as a list.
tag_id | stap_s | stap_t | lat_s | lon_s | lat_t | lon_t | s | t | j | start | end | n | distance | bearing | gs_u | gs_v | ws_u | ws_v |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
16LN | 1 | 2 | -22.7 | 28.8 | -20.1 | 26.6 | 8503 | 21109 | 1 | 2017-04-04 19:42:30 | 2017-04-05 03:52:30 | 1 | 363.6 | -38.1 | -26.9 | 31.4 | -28.0 | -3.5 |
16LN | 2 | 3 | -20.1 | 26.6 | -18.9 | 26.4 | 21109 | 34936 | 1 | 2017-04-05 17:37:30 | 2017-04-05 21:12:30 | 1 | 140.8 | -10.8 | -6.0 | 31.7 | -13.8 | -1.0 |
16LN | 3 | 4 | -18.9 | 26.4 | -18.1 | 27.1 | 34936 | 49373 | 1 | 2017-04-06 01:02:30 | 2017-04-06 03:42:30 | 1 | 114.7 | 43.8 | 23.0 | 24.0 | -2.3 | -0.1 |
16LN | 4 | 5 | -18.1 | 27.1 | -17.1 | 26.6 | 49373 | 63049 | 1 | 2017-04-06 23:52:30 | 2017-04-07 03:07:30 | 1 | 122.7 | -25.7 | -12.9 | 26.9 | -16.9 | -9.8 |
16LN | 5 | 6 | -17.1 | 26.6 | -17.1 | 27.4 | 63049 | 77489 | 1 | 2017-04-07 18:17:30 | 2017-04-07 21:12:30 | 1 | 79.8 | 90.1 | 18.2 | 0.0 | -9.5 | -3.5 |
16LN | 6 | 7 | -17.1 | 27.4 | -15.6 | 25.6 | 77489 | 90403 | 1 | 2017-04-08 17:37:30 | 2017-04-08 22:17:30 | 1 | 250.0 | -48.6 | -36.0 | 31.7 | -23.2 | 3.4 |
Here is an example showing all the tracks
Code
bird_data <- paths(pkg) %>%
filter(type == "most_likely")
# Generate a color palette for unique tag IDs
tag_ids <- unique(bird_data$tag_id)
color_palette <- colorFactor(palette = "Set1", domain = tag_ids)
leaflet_map <- leaflet(height = 600) %>% addTiles()
# Add polylines and markers for each tag_id
for (tag in tag_ids) {
bird_subset <- bird_data %>% filter(tag_id == tag)
leaflet_map <- leaflet_map %>%
addPolylines(
lng = ~lon,
lat = ~lat,
data = bird_subset,
color = color_palette(tag),
weight = 2,
popup = ~ paste0("Tag ID: ", tag_id, "<br>Step: ", stap_id)
) %>%
addCircleMarkers(
lng = ~lon,
lat = ~lat,
data = bird_subset,
color = color_palette(tag),
radius = 4,
fillOpacity = 0.8,
popup = ~ paste0("Tag ID: ", tag_id, "<br>Step: ", stap_id)
)
}
# Add a legend
leaflet_map <- leaflet_map %>%
addLegend(
position = "topright",
pal = color_palette,
values = tag_ids,
title = "Bird Trajectories",
opacity = 1
)
# Display the map
leaflet_map