Skip to content

Commit

Permalink
version 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Cl�ment Calenge authored and gaborcsardi committed Feb 21, 2006
1 parent b2751e0 commit d4e3540
Show file tree
Hide file tree
Showing 226 changed files with 6,563 additions and 6,073 deletions.
38 changes: 37 additions & 1 deletion CONTENTS 100644 → 100755
Expand Up @@ -22,6 +22,12 @@ Keywords: hplot
Description: Working with several Raster Maps
URL: ../../../library/habitat/html/as.kasc.html

Entry: as.ltraj
Aliases: as.ltraj, ltraj, print.ltraj, summary.ltraj, traj2ltraj, ltraj2traj
Keywords: spatial
Description: Working with Trajectories in 2D Space: the Class ltraj
URL: ../../../library/habitat/html/as.ltraj.html

Entry: as.sahrlocs
Aliases: as.sahrlocs, getsahrlocs, print.sahrlocs
Keywords: spatial
Expand Down Expand Up @@ -64,6 +70,12 @@ Keywords: spatial
Description: Compute Buffers
URL: ../../../library/habitat/html/buffer.html

Entry: c.ltraj
Aliases: c.ltraj
Keywords: spatial
Description: Combine Bursts of Relocations in Objects of Class "ltraj"
URL: ../../../library/habitat/html/c.ltraj.html

Entry: chamois
Aliases: chamois
Keywords: dataset
Expand Down Expand Up @@ -106,12 +118,30 @@ Keywords: spatial
Description: Estimation of the Potential Distribution of a Species
URL: ../../../library/habitat/html/domain.html

Entry: eisera
Aliases: eisera, print.esr, scatter.esr
Keywords: multivariate
Description: Eigenanalysis of Selection Ratios
URL: ../../../library/habitat/html/eisera.html

Entry: Extract.ltraj
Aliases: Extract.ltraj, [.ltraj, [<-.ltraj
Keywords: spatial
Description: Extract or Replace Parts of an Object of Class ltraj
URL: ../../../library/habitat/html/Extract.ltraj.html

Entry: enfa
Aliases: enfa, hist.enfa, print.enfa, data2enfa, print.dataenfa
Keywords: multivariate
Description: Ecological-Niche Factor Analysis
URL: ../../../library/habitat/html/enfa.html

Entry: gdltraj
Aliases: gdltraj
Keywords: spatial
Description: Working with Trajectories: Specify a Time Period
URL: ../../../library/habitat/html/gdltraj.html

Entry: getascattr
Aliases: getascattr
Keywords: programming
Expand Down Expand Up @@ -180,7 +210,7 @@ Description: Multivariate analyses of objects of class "kasc"
URL: ../../../library/habitat/html/df2kasc.html

Entry: kasc2spixdf
Aliases: kasc2spixdf, asc2spixdf, spixdf2kasc, area2sr, sr2area, attsr2area, traj2spdf, traj2sldf
Aliases: kasc2spixdf, asc2spixdf, spixdf2kasc, area2spol, spol2area, attpol2area, traj2spdf, traj2sldf
Keywords: hplot
Description: Conversion of maps from/to the package "sp"
URL: ../../../library/habitat/html/kasc2sgdf.html
Expand Down Expand Up @@ -264,6 +294,12 @@ Keywords: dataset
Description: Radio-Tracking of Pheasants
URL: ../../../library/habitat/html/pheasant.html

Entry: plot.ltraj
Aliases: plot.ltraj
Keywords: hplot
Description: Graphical Display of an Object of Class "ltraj"
URL: ../../../library/habitat/html/plot.ltraj.html

Entry: plot.sahrlocs
Aliases: plot.sahrlocs, print.plotsahr
Keywords: hplot
Expand Down
9 changes: 5 additions & 4 deletions DESCRIPTION 100644 → 100755
@@ -1,11 +1,12 @@
Package: adehabitat
Version: 1.3
Date: 2005/05/10
Version: 1.4
Date: 2006/02/21
Title: Analysis of habitat selection by animals
Author: Cl�ment Calenge, contributions from Mathieu Basille
Author: Cl�ment Calenge, contributions from Mathieu Basille and St�phane Dray
Maintainer: Cl�ment Calenge <calenge@biomserv.univ-lyon1.fr>
Depends: R (>= 1.8.0), ade4
Suggests: gpclib
Description: A collection of tools for the analysis of habitat selection by animals
Encoding: latin1
License: GPL version 2 or newer
Packaged: Wed May 11 10:31:46 2005; hornik
Packaged: Tue Feb 21 14:33:26 2006; Clement Calenge
31 changes: 20 additions & 11 deletions INDEX
@@ -1,15 +1,20 @@
angles Compute Turning Angles
angles Compute Turning Angles - Deprecated
area2dxf Exportation of Areas
as.area Objects of Class "area"
as.kasc Working with Several Raster Maps
as.ltraj Working with Trajectories in 2D Space: the
Class ltraj
as.sahrlocs Exploratory Analysis of Habitat Selection
as.traj Working with Trajectories in 2D Space
as.traj Working with Trajectories in 2D Space -
Deprecated
asc2im Conversion of Maps of Class 'asc' and 'im'
(Package spatstat)
ascgen Creation of Raster Maps
bighorn Radio-Tracking of Bighorn Sheeps
biv.test Bivariate Test
buffer Compute Buffers
c.ltraj Combine Bursts of Relocations in Objects of
Class "ltraj"
chamois Location of Chamois Groups in the Chartreuse
Mountains
colasc Creates a Vector of Colors for a Raster Map of
Expand All @@ -22,20 +27,24 @@ distfacmap Compute distances to the different levels of a
factor map
domain Estimation of the Potential Distribution of a
Species
eisera Eigenanalysis of Selection Ratios
enfa Ecological-Niche Factor Analysis
getascattr Copy the Attributes of an Object of Class
'asc' or 'kasc' to another Object
getcontour Computes the Contour Polygon of a Raster
Object
Extract.ltraj Extract or Replace Parts of an Object of Class
ltraj
gdltraj Working with Trajectories: Specify a Time
Period
getascattr Copy the Attributes of an Object of Class 'asc'
or 'kasc' to another Object
getcontour Computes the Contour Polygon of a Raster Object
getXYcoords Computes the X and Y Coordinates of the Pixels
of a Raster Map
hist.kasc Histograms of Mapped Variables
histniche Histograms of the Ecological Niche
hr.rast Rasterisation of Objects of Class 'area'
image.asc Displays a Color Image of an Object of Class
'asc'
image.sahrlocs Graphical Display of the Habitat Composition
of the Home Ranges of Animals Monitored Using
image.sahrlocs Graphical Display of the Habitat Composition of
the Home Ranges of Animals Monitored Using
Radio-Tracking
import.asc Arcview ASCII Raster File Importation And
Exportation
Expand Down Expand Up @@ -64,12 +73,12 @@ perarea Compute Areas and Perimeters of Objects of
Class "area"
pheasant Radio-Tracking of Pheasants
plot.area Graphical Display of Objects of Class "area"
plot.ltraj Graphical Display of an Object of Class "ltraj"
plot.sahrlocs Exploratory Analysis of Habitat Selection
predict.enfa Habitat Suitability Maps Built from the ENFA
puechabon Radio-Tracking Data of Wild Boar
puechcirc Movements of wild boars tracked at Puechabon
puechdesIII Habitat Selection by the Wild Boar at
Puechabon
puechdesIII Habitat Selection by the Wild Boar at Puechabon
rand.kselect Test of the Third-Order Habitat Selection
randtest.enfa Randomisation Test for the Ecological Niche
Factor Analysis
Expand All @@ -80,7 +89,7 @@ schoener Compute Schoener's ratio
setmask Applies a Mask on Objects of Class 'asc' or
'kasc'
speed Computes the Speed Between Successive
Relocations of an Animal
Relocations of an Animal - Deprecated
squirrel Radio-Tracking Data of Squirrels
storemapattr Store attributes of maps of class asc and kasc
subsetmap Storing a Part of a Map
Expand Down
20 changes: 20 additions & 0 deletions R/NNCH.area.r
@@ -0,0 +1,20 @@
"NNCH.area" <-
function(x, percent=c(95,90,80,70,60,50,40,30,20,10))
{
if (!inherits(x, "NNCH"))
stop("x should be of class \"NNCH\"")

res<-matrix(0,nrow=length(percent), ncol=length(x))

for (kk in 1:length(x)) {
for (i in 1:length(percent))
res[i,kk]<-x[[kk]]$area[max(which(x[[kk]]$area$levels<=percent[i])),2]
}
res<-as.data.frame(res)
row.names(res)<-percent
names(res)<-names(x)
class(res) <- c("hrsize", "data.frame")
attr(res, "units") <- attr(x, "units")
return(res)
}

95 changes: 95 additions & 0 deletions R/NNCH.r
@@ -0,0 +1,95 @@
"NNCH" <-
function(xy, id=NULL, k=10, unin = c("m", "km"),
unout = c("ha", "km2", "m2"))
{
if (ncol(xy)!=2)
stop("xy should have two columns")
if (is.null(id))
id<-rep(1,nrow(xy))
id<-factor(id)

if (k>=min(table(id)))
stop("too large number of neighbors")
if (nrow(xy)!=length(id))
stop("id should have the same length as xy")
if (min(table(id))<5)
stop("At least 5 relocations are required to fit an home range")

id <- id[!is.na(xy[, 1])]
xy <- xy[!is.na(xy[, 1]), ]
id <- id[!is.na(xy[, 2])]
xy <- xy[!is.na(xy[, 2]), ]
unin <- match.arg(unin)
unout <- match.arg(unout)
class(xy[,1])<-"double"
class(xy[,2])<-"double"
if (!require(gpclib))
stop("package gpclib required")
res<-list()

for (kk in 1:nlevels(id)) {
xyt<-xy[id==levels(id)[kk],]

li<-list()
li2<-list()
lin<-list()
lin2<-list()
ar<-0

dij<-as.matrix(dist(xyt))
idt<-1:nrow(dij)

for (i in 1:nrow(xyt)) {
iid<-idt[order(dij[i,])][1:k]
xytmp<-xyt[iid,]
ch<-chull(xytmp[,1], xytmp[,2])
li[[i]]<-as(xytmp[ch,], "gpc.poly")
lin[[i]]<-iid
}

aa<-unlist(lapply(li, area.poly))
li<-li[order(aa)]
lin<-lin[order(aa)]
idbis<-idt[order(aa)]
li2[[1]]<-li[[1]]
lin2[[1]]<-lin[[1]]

for (i in 2:length(li)) {
li2[[i]]<-union(li2[[i-1]], li[[i]])
lin2[[i]]<-unique(c(lin2[[i-1]], lin[[i]]))
}

n<-unlist(lapply(lin2, length))/nrow(xyt)
ar<-unlist(lapply(li2, area.poly))

cons<-1:length(ar)

if (unin == "m") {
if (unout == "ha")
ar <- ar/10000
if (unout == "km2")
ar <- ar/1e+06
}
if (unin == "km") {
if (unout == "ha")
ar <- ar * 100
if (unout == "m2")
ar <- ar * 1e+06
}


names(li2)<-round(n*100)
area<-data.frame(levels=round(n*100,2), area=ar)
dup<-!duplicated(area)
area=area[dup,]
row.names(area)<-1:nrow(area)
res[[levels(id)[kk]]]<-list(area=area,
polygons=li2[dup], xy=xyt)


}
attr(res, "units") <- unout
class(res)<-"NNCH"
return(res)
}

50 changes: 50 additions & 0 deletions R/NNCH.rast.r
@@ -0,0 +1,50 @@
"NNCH.rast" <-
function(y, w)
{
x <- y
if (!inherits(x, "NNCHver"))
stop("x should be of class NNCHver")
if (inherits(w, "kasc"))
w <- getkasc(w, names(w)[1])
if (!inherits(w, "asc"))
stop("w should be of class asc or kasc")

## rastérisation des polygones
hol<-lapply(lapply(x, function(y) attr(y, "pts")),
function(y) unlist(lapply(y, function(z) z$hole)))
xt<-lapply(lapply(x, function(y) attr(y, "pts")),
function(y) lapply(y, function(z) z$x))
yt<-lapply(lapply(x, function(y) attr(y, "pts")),
function(y) lapply(y, function(z) z$y))
res <- list()

for (i in 1:length(hol)) {
rr<-lapply(1:length(xt[[i]]),
function(j) mcp.rast(data.frame(x=xt[[i]][[j]],
y = yt[[i]][[j]]), w))
rr <- lapply(rr, function(o) {o[is.na(o)] <- 0; return(o)})
if (hol[[i]][1]) {
ee <- -rr[[1]]
} else {
ee <- rr[[1]]
}
if (length(rr) >1){
for (j in 2:length(rr)) {
if (hol[[i]][j])
ee <- ee - rr[[j]]
if (!hol[[i]][j])
ee <- ee + rr[[j]]
}
}
ee[ee==0] <- NA
res[[i]] <- getascattr(w, ee)
}
names(res) <- names(x)
if (length(res)==1) {
res<-res[[1]]
} else {
res <- as.kasc(res)
}
return(res)
}

0 comments on commit d4e3540

Please sign in to comment.