moveStacks are created by individuals or by deployments, depending on how you create them
Hey Bart, so Sarah and Scott realized this issue. The issue is that moveStacks are always created by individual, but when using the function getMovebankData it is created by deployment. In this example individual X4155796 has 3 deployments, so one moveObject per deployment is created. Even if there is only one deployment per individual, the @trackId name is a combination of the individual name and the deployment, and in all other cases it is only the individual name. I think a moveStack should always be the same thing, independently how you create it. And I think by individual is the most useful. Attached is the file with a subset of the downloaded data of the movebank study used in this example (I just included 10 locations per individual to make the point).
AntarcticPetrel_GPS_example.csv
library(move)
setwd("/home/anne/PowerFolders/Rstuff/MoveDocumentation/")
mylogin <- movebankLogin()
when reading in the move object directly, the moveStack is done by individual
mvcsv <- move(paste0(getwd(),"/AntarcticPetrel_GPS_example.csv"))
levels(mvcsv@trackId)
# "X4155777" "X4155796" "X4165818"
when creating the move object from a data.frame, the moveStack is done by individual
df <- read.csv(paste0(getwd(),"/AntarcticPetrel_GPS_example.csv"),as.is=T)
mvdf <- move(x=df$location.long, y=df$location.lat,
time=as.POSIXct(df$timestamp,format="%Y-%m-%d %H:%M:%S", tz="UTC"), data=df,
proj=CRS("+proj=longlat +ellps=WGS84"), animal=df$individual.local.identifier)
levels(mvdf@trackId)
# "X4155777" "X4155796" "X4165818"
when creating the move object from a data.frame downloaded with getMovebank, the moveStack is done by individual
indID <- getMovebank("individual", login=mylogin, study_id=180290122)[, c("id", "local_identifier")]
indIDsel <- indID$id[indID$local_identifier%in% c("4155777","4155796","4165818")]
attribGPS <- unique(c(as.character(getMovebankSensorsAttributes(180290122,
mylogin)$short_name[getMovebankSensorsAttributes(180290122,
mylogin)$sensor_type_id==653]), 'sensor_type_id', 'deployment_id',
'event_id', 'individual_id', 'tag_id'))
petreldf <- getMovebank("event", login=mylogin, study_id=180290122, sensor_type_id=c(653),
individual_id=indIDsel, attributes=attribGPS)
petreldf <- merge(petreldf,indID, by.x="individual_id", by.y="id")
petrelMove <- move(x=petreldf$location_long, y=petreldf$location_lat,
time=as.POSIXct(petreldf$timestamp, format="%Y-%m-%d %H:%M:%S", tz="UTC"),data=petreldf,
proj=CRS("+proj=longlat +ellps=WGS84"), animal=petreldf$local_identifier)
levels(petrelMove@trackId)
# "X4155777" "X4155796" "X4165818"
but when creating the move object with getMovebankData, the moveStack is done by deployment
petrel <- getMovebankData(study="At-sea distribution Antarctic Petrel, Antarctica 2012 (data from Descamps et al. 2016)",
animalName = c("4155777","4155796","4165818"), login=mylogin)
levels(petrel@trackId)
# "X4155777_198819719" "X4155796_198819726" "X4155796_198819730" "X4155796_198819805" "X4165818_198819866"