# NOT RUN {
## first create the login object
login <- movebankLogin()
## get Movebank ID from study
studyID <- getMovebankID(study="MPIO white stork lifetime tracking data (2013-2014)",
login=login)
studyID2 <- getMovebankID(study="BCI Ocelot", login=login)
## get a summary of information about the two studies
getMovebank("study", login=login, study_id=c(studyID,studyID2))
## get tag reference information from the study
head(getMovebank("tag", login=login, study_id=studyID))
## get animal reference information from the study
head(getMovebank("individual", login=login, study_id=studyID))
## get deployments reference information from the study
head(getMovebank("deployment", login=login, study_id=studyID))
## get the sensor measurements from the study
## find out which sensors were used in this study
unique(getMovebankSensors(study=studyID,login=login)$sensor_type_id)
## get movebank ID of one individual of this study
indID <- getMovebank("individual", login=login, study_id=studyID)$id[50]
## the correspondence table between the individual ID and the
## animal names can be obtained like this
head(getMovebank("individual", login=login,
study_id=studyID)[, c("id", "local_identifier")])
## get GPS and accelerometer data within a time period
## create a vector with attributes for all sensors included in the study
attrib <- unique(c(as.character(getMovebankSensorsAttributes(studyID,
login=login)$short_name),
'sensor_type_id', 'deployment_id', 'event_id',
'individual_id', 'tag_id'))
## get measurments for a given time period, in this case for GPS and
## accelerometer, and between "2013-06-25 03:55:00.000" and "2013-06-26 10:25:00.000"
getMovebank("event", login=login, study_id=studyID, sensor_type_id=c(653,2365683),
individual_id=indID, attributes=attrib, timestamp_start="20130625035500000",
timestamp_end="20130626102500000 ")
## get all GPS data for 2 individuals
## create a vector with attributes only for GPS data
attribs<-getMovebankSensorsAttributes(studyID, login)
attribGPS <- unique(c(as.character(attribs$short_name[attribs$sensor_type_id==653]),
'sensor_type_id', 'deployment_id', 'event_id', '
individual_id', 'tag_id'))
indID2 <- getMovebank("individual", login=login, study_id=studyID)$id[35]
## get GPS measurements for these two individuals
head(storks <- getMovebank("event", login=login, study_id=studyID,
sensor_type_id=653, individual_id=c(indID,indID2),
attributes=attribGPS))
## create moveStack
## get the names of the individuals as they appear on Movebank
(individualNames <- getMovebank("individual", login=login,
study_id=studyID)[c(35,50), c("id", "local_identifier")])
head(storks2 <- merge(storks,individualNames,by.x="individual_id", by.y="id"))
myMoveStack <- move(x=storks2$location_long, y=storks2$location_lat,
time=as.POSIXct(storks2$timestamp, format="%Y-%m-%d %H:%M:%S", tz="UTC"),
data=storks2,
proj=CRS("+proj=longlat +ellps=WGS84"),
animal=storks2$local_identifier)
plot(myMoveStack, type="l")
# }
Run the code above in your browser using DataLab