This document provides code to solve the most common issues faced when transforming tracking data in the format required for the Seabird Tracking Database https://www.seabirdtracking.org/ using R.
The script uses an artificial example than can be downloaded here: https://www.seabirdtracking.org/wp-content/uploads/2024/12/GPS_stdb_bad_example.csv
R is a free open-source software environment https://www.r-project.org/ and we recommend running R using R Studio https://posit.co/products/open-source/rstudio/
Some R packages can make the formatting easier!
library(tidyverse) #for general data wrangling
## Warning: package 'ggplot2' was built under R version 4.3.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.0
## ✔ purrr 1.0.2
## ── 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(lubridate) #for dates and times
library(leaflet) #for maps
#If you don't have a package installed use install.packages("leaflet")
Read in your tracking data csv (see the section at the end if you data is not all in one csv).
data <- read.csv("C:/Users/bethany.clark/OneDrive - BirdLife International/STDB/STDB_admin_shared_folder/GPS_stdb_bad_example.csv")
#Change the filepath to the location of your csv
head(data) #check the format
## datetime latitude longitude bird_id sex breed_stage tag_type
## 1 2015.12.05 12:13:00 -100.005 6.86970 Bird1 M brood-guard GPS
## 2 2015.12.05 13:13:00 -100.345 6.87014 Bird1 M brood-guard GPS
## 3 2015.12.05 14:13:00 -100.685 6.86029 Bird1 M brood-guard GPS
## 4 2015.12.05 15:13:00 -101.025 6.85092 Bird1 M brood-guard GPS
## 5 2015.12.05 16:13:00 -101.365 6.86155 Bird1 M brood-guard GPS
## 6 2015.12.05 17:13:00 -101.705 6.87218 Bird1 M brood-guard GPS
## trip_id
## 1 NA
## 2 NA
## 3 NA
## 4 NA
## 5 NA
## 6 NA
#Remove NAs in the key variables
nrow(data)
## [1] 46
data <- data %>% drop_na(latitude, latitude, datetime)
nrow(data) #Check the difference between the number of rows before and after, and investigate if needed
## [1] 44
Common issues include:
- Positions outside the boundaries e.g. lat >90 or < -90, lon
>180 or < -180
- Locations before or after deployment (e.g. of the institute, not the
bird!)
- Lat/lon reversed
summary(data$latitude);summary(data$longitude)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -109.53 -105.87 -102.22 -98.34 -98.07 0.00
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 6.870 6.965 6.842 7.102 7.448
plot(data$longitude,data$latitude)