Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2751e0
commit d4e3540
Showing
226 changed files
with
6,563 additions
and
6,073 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
|
Oops, something went wrong.