From 97d0de3c2f84ae58df78de331cfcfc0a91378e2d Mon Sep 17 00:00:00 2001 From: Clement Calenge Date: Fri, 14 Dec 2007 00:00:00 +0000 Subject: [PATCH] version 1.7.1 --- CONTENTS | 6 ++ DESCRIPTION | 6 +- INDEX | 5 ++ R/angles.r | 100 +++++++++++++++++++++++++++++++++ R/kerneloverlap.R | 131 +++++++++++++++++++++++++++++++++++++++++++ R/speed.r | 38 +++++++++++++ R/subsetmap.asc.r | 10 ++-- data/puechcirc.rda | Bin man/angles.Rd | 95 +++++++++++++++++++++++++++++++ man/is.sd.Rd | 10 ++-- man/kerneloverlap.Rd | 110 ++++++++++++++++++++++++++++++++++++ man/speed.Rd | 62 ++++++++++++++++++++ man/subsetmap.Rd | 3 +- src/tests.c | 3 +- 14 files changed, 564 insertions(+), 15 deletions(-) create mode 100755 R/angles.r create mode 100644 R/kerneloverlap.R create mode 100755 R/speed.r mode change 100644 => 100755 data/puechcirc.rda create mode 100755 man/angles.Rd create mode 100644 man/kerneloverlap.Rd create mode 100755 man/speed.Rd diff --git a/CONTENTS b/CONTENTS index a319f10..dbcb98b 100755 --- a/CONTENTS +++ b/CONTENTS @@ -353,6 +353,12 @@ Keywords: spatial Description: Estimation of kernel home-range URL: ../../../library/adehabitat/html/kernelUD.html +Entry: kerneloverlap +Aliases: kerneloverlap +Keywords: spatial +Description: Spatial Interaction between Animals Monitored Using Radio-Tracking +URL: ../../../library/adehabitat/html/kerneloverlap.html + Entry: kselect Aliases: kselect, kplot.kselect, hist.kselect, print.kselect Keywords: multivariate diff --git a/DESCRIPTION b/DESCRIPTION index c7e2065..eb18f75 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: adehabitat -Version: 1.7 -Date: 2007/08/29 +Version: 1.7.1 +Date: 2007/12/14 Title: Analysis of habitat selection by animals Author: Clement Calenge, contributions from Mathieu Basille, Stephane Dray and Scott Fortmann-Roe Maintainer: Clement Calenge @@ -9,4 +9,4 @@ Suggests: gpclib, sp, spatstat, MASS, tkrplot, shapefiles, CircStats Description: A collection of tools for the analysis of habitat selection by animals Encoding: latin1 License: GPL version 2 or newer -Packaged: Wed Aug 29 12:35:56 2007; calenge +Packaged: Fri Dec 14 17:31:10 2007; calenge diff --git a/INDEX b/INDEX index 3aafbb3..5ed9357 100644 --- a/INDEX +++ b/INDEX @@ -3,6 +3,7 @@ adehabitat-package adehabitat: a Package for the Analysis of the albatross Argos Monitoring of Adult Albatross Movement altr Attach or Detach Bursts in Objects of Class 'ltraj' to Search Path +angles Compute Turning Angles - Deprecated area2asc Converts a Polygon to Raster area2dxf Exportation of Areas as.area Objects of Class "area" @@ -86,6 +87,8 @@ join.asc Finds the Value of Mapped Variables at some kasc2df Conversion of Objects of Class kasc kasc2spixdf Conversion of maps from/to the package "sp" kernelbb Estimation of Kernel Brownian Bridge Home-Range +kerneloverlap Spatial Interaction between Animals Monitored + Using Radio-Tracking kernelUD Estimation of Kernel Home-Range kselect K-Select Analysis: a Method to Analyse the Habitat Selection by Animals @@ -161,6 +164,8 @@ simm.mou Simulation of a Bivariate Ornstein-Uhlenbeck Process sliwinltr Apply a Function on an Object of Class "ltraj", Using a Sliding Window +speed Computes the Speed Between Successive + Relocations of an Animal - Deprecated squirrel Radio-Tracking Data of Squirrels squirreloc Radio-tracking of squirrels storemapattr Store Attributes of Maps of Class asc and kasc diff --git a/R/angles.r b/R/angles.r new file mode 100755 index 0000000..31f7910 --- /dev/null +++ b/R/angles.r @@ -0,0 +1,100 @@ +"angles" <- function (x, id = levels(x$id), burst = levels(x$burst), + date = NULL, slsp = c("remove", "missing")) +{ + ## The function is deprecated + .Deprecated("as.ltraj") + + ## Verifications + if (!inherits(x, "traj")) + stop("x should be of class \"traj\"") + slsp <- match.arg(slsp) + + + ## prepangles is used to remove successive relocations + ## located at the same place + prepangles <- function(x) + { + ## Verifications + if (!inherits(x, "traj")) + stop("x should be of class \"traj\"") + + ## split per burst + li <- split(x, x$burst) + + ## keeps only the successive relocations at different places + foo <- function(y) { + oo <- unlist(lapply(2:nrow(y), + function(i) + (!all(y[i,c("x","y")]==y[i-1,c("x","y")])))) + oo <- c(TRUE,oo) + y <- y[oo,] + } + + ## output + res <- do.call("rbind", lapply(li, foo)) + return(res) + } + + ## gets the selected bursts + x <- getburst(x, burst = burst, id = id, date = date) + + ## if the angles are to be removed when successive relocations are + ## on the same place + if (slsp=="remove") + x <- prepangles(x) + + ## split per burst + li <- split(x, x$burst) + + ## To compute the angles + foo <- function(x) { + + ## gets the coordinates + xy<-as.matrix(x[,c("x","y")]) + ang<-1:(nrow(xy)-2) + + + for (i in 2:(nrow(xy)-1)) { + + ## current relocation, with the previous one + na <- 0 + ref1<-xy[i-1,] + + ## the origin of the space is placed on the previous reloc + xyb1<-t(t(xy)-ref1) + ang1<--atan2(xyb1[i,2],xyb1[i,1]) + + ## Position of rotated x2 and x3 + x2<-c(sqrt(sum(xyb1[i,]^2)), 0) + if (sum(abs(x2)) < 1e-7) + na<-1 + x3b<-x3<-xyb1[i+1,] + x3b[1]= cos(ang1)*x3[1] - sin(ang1)*x3[2] + x3b[2]= sin(ang1)*x3[1] + cos(ang1)*x3[2] + x3<-x3b + + ## Computation of the angles + x3<-x3-x2 + if (sum(abs(x3)) < 1e-7) + na<-1 + ang[i-1]<-atan2(x3[2],x3[1]) + if (na > 0.5) + if (slsp == "missing") + ang[i - 1] <- NA + } + + ## output + so<-data.frame(id=x$id[-c(1,nrow(xy))], + x=xy[-c(1,nrow(xy)),1], + y=xy[-c(1,nrow(xy)),2], + date=x$date[-c(1,nrow(xy))], + burst=x$burst[-c(1,nrow(xy))], + angles=ang) + } + + ## output + lo <- do.call("rbind", lapply(li, foo)) + row.names(lo) <- 1:nrow(lo) + return(lo) +} + diff --git a/R/kerneloverlap.R b/R/kerneloverlap.R new file mode 100644 index 0000000..cb070c8 --- /dev/null +++ b/R/kerneloverlap.R @@ -0,0 +1,131 @@ +kerneloverlap <- function(xy, id = NULL, + method = c("HR", "PHR", "VI", "BA", "UDOI", "HD"), + lev=95, conditional=FALSE, ...) +{ + ## Verifications + method <- match.arg(method) + + ## UD estimation + x <- kernelUD(xy, id, same4all=TRUE, ...) + vol <- getvolumeUD(x) + + ## Matrix of results + res <- matrix(0, ncol=length(x), nrow=length(x)) + + ## loop for each animal + for (i in 1:length(x)) { + for (j in 1:i) { + + if (method=="HR") { + vi <- vol[[i]]$UD + vj <- vol[[j]]$UD + vi[vi<=lev] <- 1 + vi[vi>lev] <- 0 + vj[vj<=lev] <- 1 + vj[vj>lev] <- 0 + vk <- vi*vj + res[i,j] <- sum(vk)/sum(vi) + res[j,i] <- sum(vk)/sum(vj) + } + + if (method=="PHR") { + vi <- x[[i]]$UD + vj <- x[[j]]$UD + ai <- vol[[i]]$UD + aj <- vol[[j]]$UD + ai[ai<=lev] <- 1 + ai[ai>lev] <- 0 + aj[aj<=lev] <- 1 + aj[aj>lev] <- 0 + if (conditional) { + vi <- vi*ai + vj <- vj*aj + res[j,i] <- sum(vi*aj)*(attr(vi,"cellsize")^2) + res[i,j] <- sum(vj*ai)*(attr(vi,"cellsize")^2) + } else { + res[j,i] <- sum(vi*aj)*(attr(vi,"cellsize")^2) + res[i,j] <- sum(vj*ai)*(attr(vi,"cellsize")^2) + } + } + + + + if (method=="VI") { + vi <- c(x[[i]]$UD) + vj <- c(x[[j]]$UD) + ai <- vol[[i]]$UD + aj <- vol[[j]]$UD + ai[ai<=lev] <- 1 + ai[ai>lev] <- 0 + aj[aj<=lev] <- 1 + aj[aj>lev] <- 0 + if (conditional) { + vi <- vi*ai + vj <- vj*aj + res[i,j] <- res[j,i] <- sum(pmin(vi, vj))*(attr(x[[i]]$UD,"cellsize")^2) + } else { + res[i,j] <- res[j,i] <- sum(pmin(vi, vj))*(attr(x[[i]]$UD,"cellsize")^2) + } + } + + if (method=="BA") { + vi <- x[[i]]$UD + vj <- x[[j]]$UD + ai <- vol[[i]]$UD + aj <- vol[[j]]$UD + ai[ai<=lev] <- 1 + ai[ai>lev] <- 0 + aj[aj<=lev] <- 1 + aj[aj>lev] <- 0 + if (conditional) { + vi <- vi*ai + vj <- vj*aj + res[j,i] <- res[i,j] <- sum(sqrt(vi)*sqrt(vj))*(attr(vi,"cellsize")^2) + } else { + res[j,i] <- res[i,j] <- sum(sqrt(vi)*sqrt(vj))*(attr(vi,"cellsize")^2) + } + } + + if (method=="UDOI") { + vi <- x[[i]]$UD + vj <- x[[j]]$UD + ai <- vol[[i]]$UD + aj <- vol[[j]]$UD + ai[ai<=lev] <- 1 + ai[ai>lev] <- 0 + aj[aj<=lev] <- 1 + aj[aj>lev] <- 0 + if (conditional) { + vi <- vi*ai + vj <- vj*aj + ak <- sum(ai*aj)*(attr(vi,"cellsize")^2) + res[j,i] <- res[i,j] <- ak * sum(vi*vj)*(attr(vi,"cellsize")^2) + } else { + ak <- sum(ai*aj)*(attr(vi,"cellsize")^2) + res[j,i] <- res[i,j] <- ak * sum(vi*vj)*(attr(vi,"cellsize")^2) + } + } + + if (method=="HD") { + vi <- x[[i]]$UD + vj <- x[[j]]$UD + ai <- vol[[i]]$UD + aj <- vol[[j]]$UD + ai[ai<=lev] <- 1 + ai[ai>lev] <- 0 + aj[aj<=lev] <- 1 + aj[aj>lev] <- 0 + if (conditional) { + vi <- vi*ai + vj <- vj*aj + res[j,i] <- res[i,j] <- sqrt(sum((sqrt(vi) - sqrt(vj))^2*(attr(vi,"cellsize")^2))) + } else { + res[j,i] <- res[i,j] <- sqrt(sum((sqrt(vi) - sqrt(vj))^2*(attr(vi,"cellsize")^2))) + } + } + } + } + rownames(res) <- names(x) + colnames(res) <- names(x) + return(res) +} diff --git a/R/speed.r b/R/speed.r new file mode 100755 index 0000000..aa31831 --- /dev/null +++ b/R/speed.r @@ -0,0 +1,38 @@ +"speed" <- function(x, id=levels(x$id), burst=levels(x$burst), + date=NULL, units=c("seconds", "hours","days")) +{ + ## Verifications + .Deprecated("as.ltraj") + if (!inherits(x, "traj")) + stop("should be an object of class traj") + units<-match.arg(units) + + ## Selection of dates + x<-getburst(x, burst=burst, id=id, date=date) + + ## distances between successives relocations + li<-split(x, x$burst) + foo<-function(x) { + x1<-x[-1,] + x2<-x[-nrow(x),] + dist<-sqrt( (x1$x-x2$x)^2 + (x1$y-x2$y)^2) + hour<-(unclass(x1$date)-unclass(x2$date)) + if (units=="hours") + hour<-(unclass(x1$date)-unclass(x2$date))/3600 + if (units=="days") + hour<-(unclass(x1$date)-unclass(x2$date))/(3600*24) + disx<-(x1$x-x2$x) + disy<-(x1$y-x2$y) + so<-cbind.data.frame(id=x2$id,x=x2$x, y=x2$y, date=x2$date, + burst=x2$burst, + sp.x=disx/hour, sp.y=disy/hour, + speed=dist/hour, dt=hour) + return(so) + } + + ## Output + lo<-do.call("rbind", lapply(li, foo)) + row.names(lo)<-1:nrow(lo) + return(lo) +} + diff --git a/R/subsetmap.asc.r b/R/subsetmap.asc.r index 45f2117..0c24aaa 100755 --- a/R/subsetmap.asc.r +++ b/R/subsetmap.asc.r @@ -21,13 +21,13 @@ cs<-attr(x, "cellsize") ## Gets the indices of the limits of the new map - posli1<-round((xlim[1]-xll)/cs, 0)+1 - posco1<-round((ylim[1]-yll)/cs, 0)+1 - posli2<-round((xlim[2]-xll)/cs, 0)+1 - posco2<-round((ylim[2]-yll)/cs, 0)+1 + posli1<-floor((xlim[1]-xll)/cs)+1 + posco1<-floor((ylim[1]-yll)/cs)+1 + posli2<-floor((xlim[2]-xll)/cs)+1 + posco2<-floor((ylim[2]-yll)/cs)+1 ## Gets the new map - o<-x[posli1:posli2,posco1:posco2] + o<-x[posli1:posli2,posco1:posco2, drop=FALSE] ## Sets the attributes of the new map attr(o, "xll")<-xy$x[posli1] diff --git a/data/puechcirc.rda b/data/puechcirc.rda old mode 100644 new mode 100755 diff --git a/man/angles.Rd b/man/angles.Rd new file mode 100755 index 0000000..6c03716 --- /dev/null +++ b/man/angles.Rd @@ -0,0 +1,95 @@ +\name{angles} +\alias{angles} +\title{Compute Turning Angles - Deprecated} +\description{ + \code{angles} computes the turning angles (in radians) between + consecutive moves from an object of class \code{traj}. See examples + for a clearer definition. +} +\usage{ +angles(x, id = levels(x$id), burst = levels(x$burst), + date = NULL, slsp = c("remove", "missing")) +} +\arguments{ + \item{x}{an object of class \code{traj} } + \item{id}{a character vector giving the identity of the animals for which + the angles are to be computed} + \item{burst}{a character vector giving the identity of the circuits for which + the angles are to be computed (see \code{traj})} + \item{date}{a vector of class \code{POSIXct} of length 2 (beginning, end) + delimiting the period of interest} + \item{slsp}{a character string. If \code{"remove"}, successive + relocations located at the same place are replaced by a single + relocation, allowing the computation of the angles. If + \code{"missing"}, a missing value is returned for the angles when + successive relocations located at the same place. } +} +\value{ + Returns a data frame with the following components: + \item{id}{the identity of the animal} + \item{x}{the x coordinate of the relocation at which the angle is computed} + \item{y}{the y coordinate of the relocation at which the angle is computed} + \item{date}{a vector of class \code{POSIXct}, giving the date at which + the relocation has been taken} + \item{burst}{the id of the circuit (see \code{help(traj)})} + \item{angles}{the turning angles between the successive moves.} +} +\references{ + Turchin, P. (1998) \emph{Quantitative analysis of movement. Measuring + and modeling population redistribution in animals and plants.} + Sunderland, Massachusetts: Sinauer Associates. +} +\author{ Clement Calenge \email{calenge@biomserv.univ-lyon1.fr} } +\note{ + The function \code{angles} is deprecated. The class \code{ltraj} + computes the turning angles automatically (see \code{ltraj}). +} +\seealso{ \code{\link{speed}} for computation of movement speeds, + \code{\link{traj}} for additional information about objects of + class \code{traj} } +\examples{ + +\dontrun{ +## loads an object of class "traj" +data(puechcirc) +puechcir <- ltraj2traj(puechcirc) +puechcir + +## Gets a part of the trajectory of the wild boar named +## CH93 and draws it +## Also displays the turning angles +toto <- puechcir[2:5,] +plot(toto$x, toto$y, asp = 1, ylim = c(3158300, 3158550), + pch = 16, + main = "Turning angles between\nthree consecutive moves", + xlab="X", ylab="Y") +lines(toto$x, toto$y) +lines(c(toto$x[2], 700217.6), + c(toto$y[2], 3158310), lty=2) +lines(c(toto$x[3],700289), + c(toto$y[3],3158546), lty=2) +ang1x <- c(700234.8, 700231.9, 700231, 700233.7, 700238.8, 700243.2) +ang1y <- c(3158332, 3158336, 3158341, 3158347, 3158350, 3158350) +ang2x <- c(700283.3, 700278.8, 700275.4, 700272.4, 700271.2, 700271.6, + 700274.7) +ang2y <- c(3158522, 3158522, 3158520, 3158517, 3158514, 3158508, 3158504) +lines(ang1x, ang1y) +lines(ang2x, ang2y) +text(700216.1, 3158349, expression(theta[1]), cex=2) +text(700247.7, 3158531, expression(theta[2]), cex=2) +text(c(700301, 700231), c(3158399, 3158487), + c("Beginning", "End"), pos=4) + + + +## Computation of the turning angles with real data +## on wild boars +plot(puechcir) +ang <- angles(puechcir) + +## The angles are in the column angles: +ang[1:4,] +} + +} +\keyword{spatial} diff --git a/man/is.sd.Rd b/man/is.sd.Rd index 8653866..1081334 100644 --- a/man/is.sd.Rd +++ b/man/is.sd.Rd @@ -60,16 +60,16 @@ is.sd(bea2) df <- sd2df(bea2, "dist") ## Plots the average distance per hour -meandi <- apply(df, 1, mean, na.rm = TRUE) -sedi <- apply(df, 1, sd, na.rm = TRUE) / sqrt(ncol(df)) -plot(seq(0, 24, length = 48), +meandi <- apply(df[-nrow(df),], 1, mean, na.rm = TRUE) +sedi <- apply(df[-nrow(df),], 1, sd, na.rm = TRUE) / sqrt(ncol(df)) +plot(seq(0, 23.5, length = 47), meandi, ty = "b", pch = 16, xlab = "Hours (time 0 = 22H00)", ylab="Average distance covered by the bear in 30 mins", ylim=c(0, 500)) -lines(seq(0, 24, length = 48), +lines(seq(0, 23.5, length = 47), meandi+sedi, col="grey") -lines(seq(0, 24, length = 48), +lines(seq(0, 23.5, length = 47), meandi-sedi, col="grey") diff --git a/man/kerneloverlap.Rd b/man/kerneloverlap.Rd new file mode 100644 index 0000000..ad8ec44 --- /dev/null +++ b/man/kerneloverlap.Rd @@ -0,0 +1,110 @@ +\name{kerneloverlap} +\alias{kerneloverlap} +\title{Spatial Interaction between Animals Monitored Using Radio-Tracking} +\description{ + This function implements all the indices of kernel home-range overlap + reviewed by Fieberg and Kochanny (2005). +} +\usage{ +kerneloverlap(xy, id = NULL, method = c("HR", "PHR", "VI", "BA", "UDOI", "HD"), lev = 95, conditional = FALSE, \dots) +} +\arguments{ + \item{xy}{a data frame with two columns (x and y coordinates of the + animal relocations)} + \item{id}{a factor giving the animals identity associated to + \code{xy}} + \item{method}{the desired method for the estimation of overlap (see + details)} + \item{lev}{the level of the home range estimation} + \item{conditional}{logical. If \code{TRUE}, the function sets to 0 + the pixels of the grid over which the UD is estimated, + outside the home range of the animal estimated at a level of + probability equal to \code{lev}. Note that this argument has no + effect when \code{meth="HR"}.} + \item{\dots}{additional arguments to be passed to the function + \code{kernelUD} for the kernel estimation of the utilization + distribution.} +} +\details{ + Fieberg and Kochanny (2005) made an extensive review of the indices of + overlap between utilization distributions (UD) of two animals. The + function \code{kerneloverlap} implements these indices. The argument + \code{method} allows to choose an index\cr + + The choice \code{method="HR"} computes the proportion of the home + range of one animal covered by the home range of another one, i.e.: + \deqn{HR_{i,j} = A_{i,j} / A_i}{HR[i,j] = A[i,j] / A[i]}, + where \eqn{A_{i,j}}{A[i,j]} is the area of the intersection between + the two home ranges and \eqn{A_i}{A[i]} is the area of the home range + of the animal i.\cr + + The choice \code{method="PHR"} computes the volume under the UD of the + animal j that is inside the home range of the animal i (i.e., the + probability to find the animal j in the home range of i). That is: + \deqn{PHR_{i,j} = \int \int_{A_i} UD_j(x,y) dxdy}{PHR[i,j] = + integral_over_x integral_over_y A[i] UD[j](x,y) dxdy} where + \eqn{UD_j(x,y)}{UD[j](x,y)} is the value of the utilization + distribution of the animal j at the point x,y.\cr + + The choice \code{method="VI"} computes the volume of the intersection + between the two UD, i.e.: + \deqn{VI = \int_x \int_y min(UD_i(x,y),UD_j(x,y)) dxdy}{VI = + integral_over_x integral_over_y min(UD[i](x,y),UD[j](x,y)) dxdy}\cr + + Other choices rely on the computation of the joint distribution of the + two animals under the hypothesis of independence UD[i](x,y) * + UD[j](x,y). + + The choice \code{method="BA"} computes the Bhattacharyya's affinity + \deqn{BA = \int_x \int_y \sqrt{UD_i(x,y)} \times \sqrt{UD_j(x,y)}}{BA = + integral_over_x integral_over_y sqrt(UD[i](x,y)) * sqrt(UD[j](x,y))}\cr + + The choice \code{method="UDOI"} computes a measure similar to the + Hurlbert index of niche overlap: + \deqn{UDOI = A_{i,j} \int_x \int_y UD_i(x,y) \times + UD_j(x,y)}{UDOI = A[i,j] integral_over_x integral_over_y UD[i](x,y) * + UD[j](x,y)}\cr + + The choice \code{method="HD"} computes the Hellinger's distance: + \deqn{HD = \int_x \int_y ((\sqrt UD_i(x,y) - \sqrt UD_j(x,y))^2 + dxdy)^{1/2}}{HD = integral_over_x integral_over_y ((sqrt(UD[i](x,y) - + sqrt(UD[j](x,y)))^2 dxdy)^(1/2))}\cr + +} +\value{ + A matrix giving the value of indices of overlap for all pairs of + animals. +} +\references{ +Fieberg, J. and Kochanny, C.O. (2005) Quantifying home-range overlap: the +importance of the utilization distribution. \emph{Journal of Wildlife + Management}, \bold{69}, 1346--1359. +} +\author{Clement Calenge \email{calenge@biomserv.univ-lyon1.fr}, + based on a work of John Fieberg} +\seealso{\code{\link{kernelUD}} for additional information on kernel + estimation of home ranges} +\examples{ + +data(puechabon) + +kerneloverlap(puechabon$locs[,c("X","Y")], puechabon$locs$Name, + grid=200, meth="VI", conditional=TRUE) + +kerneloverlap(puechabon$locs[,c("X","Y")], puechabon$locs$Name, + grid=200, meth="HR") + +kerneloverlap(puechabon$locs[,c("X","Y")], puechabon$locs$Name, + grid=200, meth="PHR") + +kerneloverlap(puechabon$locs[,c("X","Y")], puechabon$locs$Name, + grid=200, meth="BA") + +kerneloverlap(puechabon$locs[,c("X","Y")], puechabon$locs$Name, + grid=200, meth="UDOI") + +kerneloverlap(puechabon$locs[,c("X","Y")], puechabon$locs$Name, + grid=200, meth="HD") + +} +\keyword{spatial} diff --git a/man/speed.Rd b/man/speed.Rd new file mode 100755 index 0000000..1e1e69b --- /dev/null +++ b/man/speed.Rd @@ -0,0 +1,62 @@ +\name{speed} +\alias{speed} +\title{Computes the Speed Between Successive Relocations of an Animal + - Deprecated} +\description{ + \code{speed} measures the speed between successive relocations of + animals, using objects of class \code{traj}. +} +\usage{ +speed(x, id = levels(x$id), burst = levels(x$burst), date = NULL, + units = c("seconds", "hours", "days")) +} +\arguments{ + \item{x}{an object of class \code{traj}} + \item{id}{a character vector giving the identity of the animals for + which the speed is to be computed} + \item{burst}{a character vector giving the identity of the circuits + for which the speed is to be computed (see \code{traj})} + \item{date}{a vector of class \code{POSIXct} of length 2 (beginning, end) + delimiting the period of interest} + \item{units}{a character string. It determines how the + speeds are computed. For example, if the coordinates are given in + meters, and if \code{units = "seconds"}, speeds are returned in + meters per second.} +} +\value{ + Returns a data frame with the following components: + \item{id}{the identity of the animal} + \item{x}{if the speed is computed between the relocation 1 and 2, + the x coordinate of the relocation 1.} + \item{y}{if the speed is computed between the relocation 1 and 2, + the y coordinate of the relocation 1.} + \item{date}{a vector of class \code{POSIXct}, giving the date of + relocation 1.} + \item{burst}{the identity of the circuit} + \item{sp.x}{the computed speed of the animal in the x direction} + \item{sp.y}{the computed speed of the animal in the y direction} + \item{speed}{the computed speed of the animal on the plane.} + \item{dt}{the duration between the two relocations (in the units given + by the parameter \code{units}).} +} +\author{ Clement Calenge \email{calenge@biomserv.univ-lyon1.fr} } +\note{ + The function \code{speed} is deprecated. The class \code{ltraj} + computes the speeds automatically (see \code{ltraj}). +} +\seealso{ \code{\link{traj}}} +\examples{ +\dontrun{ +#### Computes the speed for each wild boar +#### monitored at Puechabon +data(puechcirc) +puechcirc <- ltraj2traj(puechcirc) +puechcirc + +plot(puechcirc) +sp <- speed(puechcirc) +sp[1:4,] +} +} +\keyword{spatial} + diff --git a/man/subsetmap.Rd b/man/subsetmap.Rd index 0ab1de4..4d23c92 100755 --- a/man/subsetmap.Rd +++ b/man/subsetmap.Rd @@ -27,7 +27,8 @@ subsetmap(x, xlim = NULL, ylim = NULL, ...) \value{ Returns an object of class \code{asc} or \code{kasc} } -\author{Clement Calenge \email{calenge@biomserv.univ-lyon1.fr}} +\author{Clement Calenge \email{calenge@biomserv.univ-lyon1.fr}, + improvements by Jon Olav Vik} \seealso{\code{\link{asc}}, \code{\link{kasc}}} \examples{ diff --git a/src/tests.c b/src/tests.c index 5532bf9..0a9fb3e 100755 --- a/src/tests.c +++ b/src/tests.c @@ -7972,6 +7972,7 @@ void testindepangl (double *sim, double *ang, int *nang, int *debut, int *fin, i sim[j]=2*sim[j]; } + freevec(angle); } void testindepdist (double *sim, double *di, int *ndi, int *debut, int *fin, int *ndeb, int *ni){ @@ -7996,7 +7997,7 @@ void testindepdist (double *sim, double *di, int *ndi, int *debut, int *fin, int } } - + freevec(dist); }