Skip to content

relaxing the function process_moveNWT (or maybe creating a more flexible one) #3

@bniebuhr

Description

@bniebuhr

Hi!

Elie suggested the use of the function process_move_NWT for the borealrut project, for us to download and organize the data from Movebank. But for some reason the data we are using is organized in a different way. Each dataset do not present information on a single study area (or subpopulation, group, herd), but on several ones, so the information on the study area is not stored in the Reference Table from MoveBank but in a column of the dataset (called habitat).

So we adapted the function to look like this (useful only in the context of borealrut):

process_move_boreal <- function(movedata,
         CRS = "+proj=lcc +lat_1=50 +lat_2=70 +lat_0=65 +lon_0=-120 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs",
         mylogin = NULL){
  
  sf_d <- sf::st_as_sf(movedata) %>% 
    sf::st_transform(CRS)
  df <- as(movedata, "data.frame")
  df_new <- data.frame(ID = df$trackId,
                       nickname = df$nick_name,
                       DateTime = df$timestamp,
                       Lon = df$location_long,
                       Lat = df$location_lat,
                       sex = df$sex,
                       Year = lubridate::year(df$timestamp),
                       study_area = df$habitat) %>%
    dplyr::mutate(x = st_coordinates(sf_d)[,1], y =  st_coordinates(sf_d)[,2])
  
  df_new <- sf::st_as_sf(df_new, coords = c("x","y"), crs = CRS, remove = FALSE)
  return(df_new)
}

In this version of the function the argument mylogin is not used, but I was wondering the function could end somewhere in the middle of the way between this one and the current one in TuktuTools. Maybe allowing one to get info from the Reference Table (if desired, controlled by an argument) or by getting additional info from non-standard columns of the dataset (as it is the case above with the habitat variable).

What do you think?
I am taking the time to discuss it now when it is still fresh and in a way the function may be useful in a wider range of contexts...

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions