Tower ID/Lat/Long issues when downloading data

Hi everyone, this is my first time posting in the Motus community, so I apologize in advance if this issue has already been resolved in another post.

I’m working with Motus data in the Pacific Northwest, and after filtering and summarizing detections, I am seeing that the majority of my detections are at receivers that have no ID, name, Lat, or Lon. So mostly NAs in those fields. I’m sure some of them are problem detections, but I know that a bunch of them are true detections (based on the motus website and how extremely likely those towers would be to detect our birds).

Has anyone else encountered this? I’m not sure if there is a way to fix this from the motus system, or if I need to manually enter the information myself? There are well over 100 detections like this, and I would like to avoid manual imput if I can since I don’t want to create more issues later down the line.

Thank you!!

Hi Sam,

I was playing with the Beta data viewer and downloading the pre-processed detection data from that, and one issue I found with that data was one station in Oregon had a comma in the name. I forget which one it was, but it was something like Wood River, OR. In my downloaded data, all the rows that included that column were shifted to the right, so there were extra columns to the right of the .csv files. It wasn’t super easy to find in R, but I was getting weird errors when trying to convert lat longs to spatial points or do time conversions, but it was easy to find when looking at the .csv file in Excel. So depending on how you’re downloading and trying to view your data, I’d suggest exporting the full table into a .csv and looking at it in Excel just to see if any columns are shifting over from weird naming conventions (including commas, etc). That might not be an issue, but it could help with detective work to figure out if there is anything weird going on with those detections that might not be apparent once you filter down the columns you are working with. I alerted Motus about the commas in the station names a few weeks ago, and again I don’t think that would be the issue when downloading the data through the R package, but there could be something similar going on. What project are you downloading data off of? I’d be happy to peak at it, just cause I’m trying to streamline my data downloading right now… -Gabe

Hi Gabriel,

Thank you for your help! I don’t think the issue is from a column shift, and I’ve double checked with the original download as well to make sure if wasn’t being hidden by my filtering.

I’m working with project 434 (British Columbia Northern Saw-whet Owls), I would greatly appreciate your help to figure out what’s going on!!

Thanks!! - Sam

Hi Sam,

Are you able to look at the tagDeps and recvDeps tables (before joining them with the detection data) and check if there is data in them or if they’re empty or partially empty?

I can try to take a look at your data too, but I might not get to it right away.

Cheers, Amie

Hi Amie,

Thanks for your help! I looked at the recvDeps and tagDeps tables and they don’t look empty, or even partially empty. The recvDeps table is the table of all possible receivers that you are referring to?

Thank you for you help in trying to get to the bottom of this!

Best, Sam

Hi Sam,

I took a look at your data and I’m not getting the same thing - for the most part the detections are at receivers with IDs and names. When you downloaded the data in R, did the download complete? Or was there a timeout or other error that stopped it early?

I did get 55 hits that were missing recv ID and names (out of a total 174985 hits, so a tiny fraction of the hits), but those were all run lengths of two except for 3 runs of length3 or 4. So I’d be inclined to believe those are false positives that can be removed anyway. Here’s a snippet of my code:

library(motus)
library(tidyverse)
library(lubridate)

# set timezone
Sys.setenv(TZ = "GMT")

# download/update project database and receiver databases (change to new = FALSE after first time downloading)
tagme(projRecv = 434, new = TRUE, update = TRUE, forceMeta = TRUE, dir = "sql-databases/")

# file path to sql database files
path <- "./sql-databases/"

#### pull out metadata for all project 434 tags #### 

# in the motus species list NSWO = 7680
# double check species codes
sqldb <- tagme(projRecv = 434, new = FALSE, update = FALSE, dir = path)

sp.list <- c(7680) # nswo

species <- tbl(sqldb, "species") %>%
  filter(id %in% sp.list) %>%
  collect() %>%
  as.data.frame()

# get tag metadata
tagmet <- tbl(sqldb, "tagDeps")

tags.meta <- tagmet %>%
  select(deployID, tagID, projectID, tsStart, tsEnd, deferSec, speciesID,
         markerNumber, latitude, longitude, fullID, comments) %>%
  filter(speciesID %in% sp.list) %>%
  collect() %>%
  as.data.frame() %>% # once in df format, can format dates with lubridate
  mutate(tsStart = as_datetime(tsStart, tz = "UTC", origin = "1970-01-01"),
         tsEnd = as_datetime(tsEnd, tz = "UTC", origin = "1970-01-01")) %>% 
  distinct() %>%
  filter(!is.na(longitude)) %>%
  group_by(tagID) %>%
  mutate(n = n()) %>%
  ungroup()

# get ambiguous tag info
allambigs <- tbl(sqldb, "allambigs")

ambig <- allambigs %>%
  collect() %>%
  as.data.frame()

# check if any tags interested in have ambiguous detections
tags.ambigs <- ambig %>% 
  group_by(ambigID) %>%
  mutate(inds = ifelse(any(motusTagID %in% tags.meta$tagID), "yes","no")) %>%
  filter(inds == "yes") %>%
  ungroup() %>%
  rename(tagID = motusTagID)

# get tag list (includes tags interested in and relevant ambiguous tags)
tag.list <- tags.meta %>%
  select(tagID) %>%
  bind_rows(., tags.ambigs %>% select(tagID)) %>%
  distinct() %>% pull()

# alltags dataset 
system.time({
  
  alltag <- tbl(sqldb, "alltags")
  
  tags.detect <- alltag %>%
    filter(tagProjID == 434 & motusTagID %in% tag.list) %>%
    select(hitID, runID, batchID, ts, sig, port, noise, freqsd, motusTagID,
           ambigID, runLen, tagProjID, tagDeployID, tagDeployStart, tagDeployEnd,
           tagDepLat, tagDepLon, deviceID, recvDeployID, recv,
           speciesSci, markerNumber, mfg, mfgID) %>%
    collect() %>%
    as.data.frame() %>%
    mutate(ts = as_datetime(ts, tz = "UTC", origin = "1970-01-01"),
           tagDeployStart = as_datetime(tagDeployStart, tz = "UTC", origin = "1970-01-01"),
           tagDeployEnd = as_datetime(tagDeployEnd, tz = "UTC", origin = "1970-01-01"))
  
})

any(is.na(tags.detect$recvDeployID))

tags.detect.na <- tags.detect %>% filter(is.na(recvDeployID))

tags.detect.na %>% select(runLen) %>% group_by(runLen) %>% summarize(n = n())

You can see I commented out the lines where I usually remove detections at receivers with no ID or coordinates. I’d be curious if this works for you? I can share more code if it does.

Amie

Hi Amy!

Thank you for helping me troubleshoot! Despite having tried updating the database several times before coming to the motus community, that didn’t seem help. So I deleted my motus download and restarted from the beginning (as you would have had to do) and it worked! I now have the same few hits with missing recvID. Thank you for your help with this and for taking the time to help me trouble shoot! I’m so curious why the data didn’t download properly the first time because I monitored for time-out problems but those never came up in the original download.

Happy happy holidays:) Sam

1 Like

Wanted to say that this thread helped me with the same problem. Using this example the secret was forcing the metadata to get pulled again:

download/update project database and receiver databases (change to new = FALSE after first time downloading)

tagme(projRecv = 434, new = FALSE, update = FALSE, forceMeta = TRUE, dir = “sql-databases/”)