library(knitr) opts_chunk$set(out.extra='style="display:block; margin: auto"', fig.align="center")
Load package library
library(lubridate) library(animalmove) library(plyr) library(ggplot2)
Buffalo dataset has been saved in the package data directory , and loaded on the package load.
Raw buffalo dataset contains unaltered original data.
data(buffalo) head(buffalo) nrow(buffalo) currentnames <- colnames(buffalo) currentnames names(buffalo)[names(buffalo)=="timestamp"] <- "time" names(buffalo)[names(buffalo)=="utm.easting"] <- "x" names(buffalo)[names(buffalo)=="utm.northing"] <- "y" names(buffalo)[names(buffalo)=="tag.local.identifier"] <- "id" names(buffalo)[names(buffalo)=="individual.taxon.canonical.name"] <- "pop.type" # Data Conversion buffalo$time <- as.POSIXct(strptime(buffalo$time,format="%Y-%m-%d %H:%M",tz="GMT")) #Display new names newnames <- colnames(buffalo) newnames head(buffalo)
Number of rows in the buffalo data & data set structure
length(table((buffalo$id))) str(buffalo)
We select at most 6 individuals within 2009, time interval 50 hours, and accuracy 50 hours, and subsampling scheme for Realized Mobility Index
pdi.subsample.data <- subsample(dat=buffalo, start=c("2005-02-17 00:00:00"),end="2006-12-31 00:00:00",interval=c("50 hours"),accuracy=c("3 hours"),minIndiv=3,maxIndiv=6,mustIndiv=NULL,index.type="pdi") buffalo.indiv <- Individuals(pdi.subsample.data, id="id", time="time", x="x", y="y", group.by="pop.type", proj4string= CRS("+proj=utm +zone=28 +datum=WGS84"))
bbox.coord1<- bbox.coordinates(buffalo.indiv, percent = 100, unin = "m", unout = "km2") bbox.coord1 specie1.scale <- bbox.scale(buffalo.indiv, percent = 100, unin = "m", unout = "km2") specie1.scale
specie1.poly <- mcp.population(buffalo.indiv, percent = 100) specie1.poly color = "green" plot(specie1.poly, col = color, axes = TRUE) points(buffalo.indiv, pch=3) title(main="Syncerus caffer", xlab="X", ylab="Y")
pdi.index.specie1 <- pdi.index(buffalo.indiv, percent = 100, specie1.scale, unin = "m", unout = "km2")
summary.specie1 <- summary.pdi(pdi.index.specie1) summary.specie1
colorSpecie1 = "pink" altColorSpecie1 = "red" plot(pdi.index.specie1, col = colorSpecie1, linecol = altColorSpecie1, title = "Syncerus caffer")
library(RColorBrewer) g = 11 my.cols <- rev(brewer.pal(g, "RdYlBu"))
require(KernSmooth) smoothScatter(pdi.subsample.data$location.long, pdi.subsample.data$location.lat, nrpoints=.3*100000, colramp=colorRampPalette(my.cols), pch=19, cex=.3, col = "green1")
library(MASS) z <- kde2d(pdi.subsample.data$location.long, pdi.subsample.data$location.lat, n=50) plot(pdi.subsample.data$location.long, pdi.subsample.data$location.lat, xlab="X", ylab="Y", pch=19, cex=.3, col = "gray60") contour(z, drawlabels=FALSE, nlevels=g, col=my.cols, add=TRUE, lwd = 2) abline(h=mean(pdi.subsample.data$location.long), v=mean(pdi.subsample.data$location.lat), lwd=2, col = "black") legend("topleft", paste("r=", round(cor(pdi.subsample.data$location.long, pdi.subsample.data$location.lat),2)), bty="n")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.