inbo / bird-tracking

🛰🐦 Bird tracking - GPS tracking network for large birds
MIT License
20 stars 7 forks source link

O_Vlieland: add behaviour data based on acceleration data #177

Closed peterdesmet closed 2 years ago

peterdesmet commented 3 years ago

From @henkjanvdkolk

O_Vlieland wil ik graag ook geclassificeerde gedragingen bij de dataset voegen, maar dit kan waarschijnlijk alleen op Zenodo en niet op Movebank? Dat wordt dan een file met kolommen BirdID(of tracker ID) + date_time_stamp + geclassificeerd gedrag

peterdesmet commented 3 years ago

It looks like this type of data can be uploaded to Movebank, as two fields:

The data itself should then be linked to the position record.

@henkjanvdkolk

  1. Do you have that data at the level of position records?
  2. Where is that data currently stored? In UvA-BiTS?
peterdesmet commented 3 years ago

Update:

After talking with @sarahcd:

peterdesmet commented 3 years ago

Code that was used to clean up the behaviour data, ending up with 6977784 records.

library(tidyverse)
library(here)
library(lubridate)

# Load behaviour data
beh <- read_csv("data/processed/O_VLIELAND/bird_ACC_2_v2.csv")
#> Rows: 7077471 Columns: 7
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr  (1): class_name
#> dbl  (5): device_info_serial, longitude, latitude, altitude, gpsspeed
#> dttm (1): date_time
#> 
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
nrow(beh)
#> [1] 7077471

# Remove duplicate rows
beh <- beh %>% distinct(.keep_all = TRUE)
nrow(beh)
#> [1] 7038045

# Create standardized values and column names
beh <-
  beh %>%
  mutate(
    `tag-id` = device_info_serial,
    timestamp = paste0(str_replace(date_time, " ", "T"), "Z"),
    timestamp_dttm = ymd_hms(timestamp),
    `behaviour-classification` = tolower(class_name)
  ) %>%
  select(`tag-id`, timestamp, timestamp_dttm, `behaviour-classification`)

# Load reference data and set future deploy-off-timestamp if NULL
ref <- read_csv("data/processed/O_VLIELAND/movebank_ref_data.csv")
#> Rows: 103 Columns: 25
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr  (13): animal-ring-id, animal-sex, animal-taxon, animal-life-stage, atta...
#> dbl   (8): animal-id, animal-mass, deploy-on-latitude, deploy-on-longitude, ...
#> lgl   (2): animal-comments, animal-nickname
#> dttm  (2): deploy-off-timestamp, deploy-on-timestamp
#> 
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
ref <- ref %>%
  mutate(`deploy-off-timestamp` = if_else(
    is.na(`deploy-off-timestamp`),
    as.POSIXct("2100-01-01T00:00:00Z", tz = "UTC"),
    `deploy-off-timestamp`
))

# Join behaviour data with reference data
# Is initially going to increase number of records for tags associated with 2
# animals, but those will disappear when selecting on timestamp within session
beh_ref <- beh %>% left_join(ref, by = "tag-id")
beh_ref <- beh_ref %>% filter(
  (timestamp_dttm >= `deploy-on-timestamp`) &
  (timestamp_dttm <= `deploy-off-timestamp`)
)
nrow(beh_ref)
#> [1] 6977784

# Export data
beh_ref <- beh_ref %>% select(`tag-id`, `animal-id`, `timestamp`, `behaviour-classification`)
write_csv(beh_ref, here::here("data", "processed", "O_VLIELAND", "movebank_beh.csv"), na = "")
peterdesmet commented 2 years ago

Behaviour data are now uploaded as Accessory Measurements: https://www.movebank.org/cms/webapp?gwt_fragment=page=studies,path=study1605802367