move (version 4.2.4)

move: Create a Move object

Description

This function creates Move or MoveStack object from a .csv file with location data downloaded from a Movebank study, from a zip file downloaded from the EnvData (environmental annotation tool) of a Movebank study, from a ltraj, telemetry, track_xyt, track or binClstPath object or from own data. If you use your own data you need to set the projection method with the 'proj' argument and specify which columns of your data contain the coordinates and timestamps.

Usage

# S4 method for connection,missing,missing,missing,missing
move(x, removeDuplicatedTimestamps=F, ...)

# S4 method for ltraj,missing,missing,missing,missing move(x, y, time, data, proj,...) # S4 method for telemetry,missing,missing,missing,missing move(x, y, time, data, proj,...) # S4 method for track_xyt,missing,missing,missing,missing move(x, y, time, data, proj,...) # S4 method for list,missing,missing,missing,missing move(x, y, time, data, proj,...) # S4 method for track,missing,missing,missing,missing move(x, y, time, data, proj,...) # S4 method for binClstPath,missing,missing,missing,missing move(x, y, time, data, proj,...) # S4 method for binClstStck,missing,missing,missing,missing move(x, y, time, data, proj,...) # S4 method for data.frame,missing,missing,missing,missing move(x, y, time, data, proj,...)

# S4 method for numeric,numeric,POSIXct,data.frame,CRS move(x, y, time, data, proj, sensor='unknown',animal='unnamed',...)

Value

returns an object of class 'move' or 'moveStack'.

If data of Movebank are used, the definitions of the content of the columns within the @idData, @sensor, @data slots of the move or moveStack object is detailed in the Attribute Dictionary on Movebank

When the move or moveStack is created providing a path to a .csv or .zip file downloaded from Movebank the coordinates in the @coords slot are named "location.long" and "location.lat". When the move or moveStack is created by providing a data.frame, the coordinates in the @coords slot are named "coords.x1" and "coords.x2".

Arguments

x

full path to the csv (or compressed) file location downloaded from a Movebank study, OR to the zip file location downloaded from the EnvData tool in Movebank.
a ltraj object from the package adehabitatLT.
a telemetry object or list of telemetry objects from the package ctmm.
a track_xyt object from the package amt.
a track object from the package bcpa.
a binClstPath or a binClstStck object from the package EMbC.
a data.frame object downloaded from Movebank webpage or with getMovebankLocationData.
numeric vector with x coordinates if non-Movebank data are provided (e.g. data$x).

y

numeric vector with y coordinates if non-Movebank data are provided (e.g. data$y).

time

vector of time stamps with POSIXct conversion if non-Movebank data are provided, i.e. as.POSIXct(data$timestamp, format="%Y-%m-%d %H:%M:%S", tz="UTC")

data

extra data associated with the relocations, if empty it is filled with the coordinates and timestamps. Optional.

proj

projection method for non-Movebank data; requires a valid CRS (see CRS-class) object, e.g. CRS("+proj=longlat +ellps=WGS84"); default is NA. Optional.

sensor

Sensor name(s), either single character or a vector with length of the number of coordinates. If multiple sensors are provided this has to be done as a vector with the same length as the number of coordinates. Optional.

animal

animal ID(s) or name(s), either single character or a vector with length of the number of coordinates. If multiple individuals are provided this has to be done as a vector with the same length as the number of coordinates. Optional.

removeDuplicatedTimestamps

logical; if TRUE duplicated timestamps values will be removed. Only available when reading in data from movebank via path to a .csv file. Using this argument will retain the first of multiple records with the same animal ID and timestamp, and remove any subsequent duplicates. See 'Note'.

...

Additional arguments

Author

Marco Smolla, Bart Kranstauber & Anne Scharf

Details

The easiest way to import data is to download the study you are interested in from https://www.movebank.org and set the file path as the x argument of the move function. The function detects whether there are single or multiple individuals in this file and automatically creates either a Move, MoveStack object. See the 'browseMovebank' vignette for more information on how to directly download data from Movebank from within R.

Another way is to read in your data using read.csv. Then specify the arguments "x" and "y" the columns of your data containing the x and y coordinates, in the argument "time" the column containing the timestamp, optionally the columns containing the information of the sensor(s) used, the animal name(s) and the projection, as well as the whole data.frame of the imported data. If the argument "animal" is left empty or contains only the name of one animal the function will return a Move object. If the data contains multiple animal names the function will return a MoveStack object.

Examples

Run this code
## create a move object from a Movebank csv file
filePath<-system.file("extdata","leroy.csv.gz",package="move")
data <- move(filePath)

## create a move object from non-Movebank data
file <- read.table(filePath, header=TRUE, sep=",", dec=".")
data <- move(x=file$location.long, y=file$location.lat, 
	     time=as.POSIXct(file$timestamp, format="%Y-%m-%d %H:%M:%S", tz="UTC"), 
	     data=file, proj=CRS("+proj=longlat +ellps=WGS84"), 
	     animal="Leroy", sensor="GPS")
plot(data, type="b", pch=20)

## if the data contain multiple individuals a moveStack will be created
fishersPath<-system.file("extdata","fishersSubset.csv.gz",package="move")
fishersSubset <- read.table(fishersPath, header=TRUE, sep=",", dec=".")
data2 <- move(x=fishersSubset$location.long, y=fishersSubset$location.lat, 
             time=as.POSIXct(fishersSubset$timestamp,format="%Y-%m-%d %H:%M:%S", tz="UTC"), 
             data=fishersSubset, proj=CRS("+proj=longlat +ellps=WGS84"),
             animal=fishersSubset$individual.local.identifier,
             sensor=fishersSubset$sensor)
plot(data2, type="b", pch=20, col=c("green","blue")[data2@idData$individual.local.identifier])
plot(data2[[2]], type="l")

# \dontshow{
move(x=1:10,y=1:10,time=as.POSIXct(1:10, origin='1970-1-1'),proj=CRS('+proj=longlat +ellps=WGS84'))
move(x=1:10,y=1:10,time=as.POSIXct(c(1:5,1:5), origin='1970-1-1'),proj=CRS('+proj=longlat +ellps=WGS84'), animal=c(rep('a',5),rep('b',5)))# }

Run the code above in your browser using DataCamp Workspace