RossDwyer / VTrack

V-Track: software for analysing and visualising animal movement from acoustic telemetry detections
https://cran.r-project.org/web/packages/VTrack/index.html
13 stars 5 forks source link

IMOS column names seem to have been updated? #24

Open lkbentley opened 1 year ago

lkbentley commented 1 year ago

Getting errors in setupData + others where the expected columns are not in the data downloaded from IMOS.

A few examples:, in the detection data setupData is looking for detection_timestamp when the column is named detection_datetime.

For Station data, package expects: deploymentdatetime_timestamp and recoverydatetime_timestamp; and instead receives: receiver_deployment_datetime and receiver_recovery_datetime.

For Transmitter data, package expects: ReleaseDate but receives transmitter_deployment_datetime.

detectionSummary is looking for a column named Tag.ID but all I have I the ATT object are Transmitter columns. Suspect further changes will come to light the more functions I use!

The obvious reason for this, I imagine, is that the IMOS export format has changed in the last couple of years. Can probably fix manually but wanted to bring to your attention. :)

Karpfen108 commented 5 months ago

I came across the same issue. It seems like several columns have changed. Below is my code and explanation that got me to run the detectionSummary.

Maybe this helps someone in the future.

upload IMOS data

data_raw <- read.csv("animal.csv")

Upload receiver metadata

receiver_raw <- read.csv("receiver.csv")

Upload tag metadata

tag_raw <-read.csv("tag.csv")

Rename the tag_id column in the data

Use the transmitter_id column in the IMOS data and tag metadata to create a new tag_id column (that is non existent before) in the tag metadata

tag_raw$tag_id <- data_raw$tag_id[match(tag_raw$transmitter_id, data_raw$transmitter_id)]

Filter out all the tag ids that are NA. If the tag doesn't exist it will put NA into the tag_id which will lead to a problem in the detSum function

tag_raw <- tag_raw[!is.na(tag_raw$tag_id), ]

Copy the measurement column into the tag_raw (For some reason the data is not provided with the tag_raw data but is required in this package)

tag_raw <- tag_raw %>% left_join((data_raw %>% distinct(tag_id, .keep_all = TRUE))[, c("tag_id", "measurement")], by = "tag_id")

Rename raw data columns to fit the VTrack functions

data_raw <- data_raw %>% rename(detection_timestamp = detection_datetime) data_raw <- data_raw %>% rename(longitude = receiver_deployment_longitude) data_raw <- data_raw %>% rename(latitude = receiver_deployment_latitude) data_raw <- data_raw %>% rename(sensor_value = transmitter_sensor_raw_value) data_raw <- data_raw %>% rename(sensor_unit = transmitter_sensor_unit)

Rename receiver columns to fit the VTrack functions

receiver_raw <- receiver_raw %>% rename(deploymentdatetime_timestamp = receiver_deployment_datetime) receiver_raw <- receiver_raw %>% rename(recoverydatetime_timestamp = receiver_recovery_datetime) receiver_raw <- receiver_raw %>% rename(station_latitude = receiver_deployment_latitude) receiver_raw <- receiver_raw %>% rename(station_longitude = receiver_deployment_longitude) receiver_raw <- receiver_raw %>% rename(status = receiver_status)

Rename tag columns to fit the VTrack functions

tag_raw <- tag_raw %>% rename(ReleaseDate = transmitter_deployment_datetime) tag_raw <- tag_raw %>% rename(common_name = species_common_name) tag_raw <- tag_raw %>% rename(scientific_name = species_scientific_name) tag_raw <- tag_raw %>% rename(sex = animal_sex) tag_raw <- tag_raw %>% rename(tag_project_name = tagging_project_name) tag_raw <- tag_raw %>% rename(release_id = transmitter_deployment_id) # not working yet. not sure which other column this could be)

tag_raw <- tag_raw %>% rename(release_latitude = transmitter_deployment_latitude) tag_raw <- tag_raw %>% rename(release_longitude = transmitter_deployment_longitude) tag_raw <- tag_raw %>% rename(tag_expected_life_time_days = transmitter_estimated_battery_life) tag_raw <- tag_raw %>% rename(tag_status = transmitter_status)

ATTdata <- setupData(Tag.Detections = data_raw, Tag.Metadata = tag_raw, Station.Information = receiver_raw, source = "IMOS")

Cheers,