column names of coords slot are different, depending on how you create the move object
Trying to use the same script/function but with moveObjets created differently, I realized that the names of the coordinates change. So depending on how the moveObject is created there are 3 different names: location.long/location.lat, location_long/location_lat or coords.x1/coords.x2. In terms of re-using a function or script, it is kind of annoying.
AntarcticPetrel_GPS_example.csv
library(move)
setwd("/home/anne/PowerFolders/Rstuff/MoveDocumentation/")
mylogin <- movebankLogin()
when reading in the move object directly, the columns are "location.long", "location.lat"
mvcsv <- move(paste0(getwd(),"/AntarcticPetrel_GPS_example.csv"))
mvcsv@coords[1,]
# location.long location.lat
# -1.238463 -65.123122
when creating the move object from a data.frame, the columns are "coords.x1", "coords.x2"
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)
mvdf@coords[1,]
# coords.x1 coords.x2
#-1.238463 -65.123122
when creating the move object from a data.frame downloaded with getMovebank, the columns are "coords.x1", "coords.x2"
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)
petrelMove@coords[1,]
# coords.x1 coords.x2
# 7.231573 -69.897235
when creating the move object with getMovebankData, the columns are "location_long", "location_lat"
petrel <- getMovebankData(study="At-sea distribution Antarctic Petrel, Antarctica 2012 (data from Descamps et al. 2016)",
animalName = c("4155777","4155796","4165818"), login=mylogin)
petrel@coords[1,]
# location_long location_lat
# 7.231573 -69.897235