[R-sig-Geo] Walruses and adehabitatHR: class estUDm exclusion of non-habitat pixels and summary over all animals
Clément Calenge
clement.calenge at oncfs.gouv.fr
Wed Jun 29 09:49:22 CEST 2011
Dear Tony,
> We wish to summarize monthly summer foraging home ranges based on daily
> locations and a daily summary of foraging behavior measured by instruments
> on-board the satellite-linked tag, which is a metric similar in nature to
> the 'activity' index utilized by Benhamou and Cornelis (2010).
>
> For each walrus with a threshold amount of tracking in each month I
> construct a utilization distribution. Then I must exclude land as
> non-habitat from each walruses monthly utilization distribution.
> Because their summering range abuts a coastline that is too complex (sharp
> peninsulas and sounds that violate the angle rules and relatively short
> shore line segments that violate the 3*h rule of Benhamou and Cornelis
> (2010)) the BRB(boundary=simpleCoastLine) option fails. As such, I am
> inclined to resort to the raster exclusion approach, whereby a
> pre-constructed raster with cell values assigned to 1 (habitat) or 0
> (non-habitat) is multiplied against each utilization distribution, all built
> on the same raster grid.
>
> Under the predecessor package, adehabitat, I would multiply each estimated
> utilization distribution (class asc) by a raster (also of class asc, read in
> using the rgdal readGDAL() function).
>
> Please advise on how to multiply out the non-habitat from the estUDm class
> object and how to normalize total volume back to 1.
>
> Also, please advise on how to summarize utilization distributions across
> walruses (in each estUDm object) to derive a single generalized utilization
> distribution for each month.
Sorry for the late reply. Actually, it is now easier to perform such
operations, as the package sp provides useful functions for such
calculations. The code below gives you an example (just copy and paste
in R):
## Load the data
library(adehabitatHR)
data(puechabonsp)
## Store the relocations
loc <- puechabonsp$relocs
## and the map
elev <- puechabonsp$map
## have a look at the data
head(as.data.frame(loc))
## the first column of this data frame is the ID
## Look at the map
image(elev)
## Now we build a "fake" habitat map (1 = habitat and 0 = non habitat)
from the elevation map
fullgrid(elev) <- TRUE
hab <- elev
hab[[1]] <- as.numeric(!is.na(hab[[1]]))
## show this habitat map (yellow is habitat)
image(hab)
## Estimation of UD for the four animals, using
## the map hab as the grid
ud <- kernelUD(loc[,1], grid=hab)
## ud is an object of the class estUDm
## Convert it to SpatialPixelsDataFrame:
udspdf <- estUDm2spixdf(ud)
## udspdf is an object of class SpatialPixelsDataFrame
## have a look
mimage(udspdf)
## Convert the original map to fullgrid (i.e. SpatialGridDataFrame)
fullgrid(udspdf) <- TRUE
## and the same for the original habitat map (here, it is not needed,
## as the map hab is already fullgrid, but it might be required on you data)
fullgrid(hab)<-TRUE
## The two maps have the same dimensions:
## > length(udspdf[[1]])
## [1] 6636
## > length(hab[[1]])
## [1] 6636
## Then, you just have to multiply each column of udspdf by the habitat
variable:
resu <- lapply(1:ncol(udspdf), function(i) {
udspdf[[i]] * hab[[1]] / sum(udspdf[[i]] * hab[[1]])
})
resu <- as.data.frame(resu)
names(resu) <- names(udspdf at data)
## and define it as data slot for udspdf
udspdf at data <- resu
## Have a look at the data (after conversion to SpatialPixelsDataFrame):
fullgrid(udspdf) <- FALSE
mimage(udspdf)
## Note that Brock and Calou, the UD have sharp limits
HTH,
Clément Calenge
--
Clément CALENGE
Cellule d'appui à l'analyse de données
Direction des Etudes et de la Recherche
Office national de la chasse et de la faune sauvage
Saint Benoist - 78610 Auffargis
tel. (33) 01.30.46.54.14
More information about the R-sig-Geo
mailing list