Population Dispersion Index

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)

Subsample Data

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)

Subsample data within time interval


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"))

Analysis

Display bounding box and scale for Specie1


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 polygon


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")

Compute PDI for each specie


pdi.index.specie1 <- pdi.index(buffalo.indiv, percent = 100, specie1.scale, unin = "m", unout = "km2")

Compute summaries of each specie PDI


summary.specie1 <- summary.pdi(pdi.index.specie1)
summary.specie1

Plot PDI


colorSpecie1 = "pink" 
altColorSpecie1 = "red"

plot(pdi.index.specie1, col = colorSpecie1, linecol = altColorSpecie1, title = "Syncerus caffer")

Extra Plotting


library(RColorBrewer)
g = 11
my.cols <- rev(brewer.pal(g, "RdYlBu"))

Smooth scatter

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")

Kernel density using MASS

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")


umd-lib/animalmove documentation built on May 3, 2019, 2:24 p.m.