Creates UD’s for autocorrelated GPS data using t-LocoH using the k(with and without time) method and the a method.
Original reference: #7322 - Lyons etal 2013
Lyons, A. J., W. C. Turner, and W. M. Getz. 2013. Home range plus: a space-time characterization of movement over real landscapes. Movement Ecology 2013.
Location to get t-LoCoH installation - Not available on CRAN or Github
install.packages(“tlocoh”, dependencies=TRUE, repos=c(“http://R-Forge.R-project.org”, “http://cran.cnr.berkeley.edu”))
knitr::opts_chunk$set(echo = TRUE)
here::here() #sets working directory
## [1] "C:/Users/20120252/Dropbox (Personal)/Statistics/Projects/Project - Foxes"
# Set the working directory to the directory of the Project using the package
# `here`.This is the equivalent to setting your working directory with
# setwd(), but is better as it links the working directory to the project
# directory and is therefore transferable between computers.
#
#list all libraries required in the script
#library(ggplot2)
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.0.5
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.4 v dplyr 1.0.7
## v tidyr 1.1.3 v stringr 1.4.0
## v readr 2.0.1 v forcats 0.5.1
## Warning: package 'ggplot2' was built under R version 4.0.5
## Warning: package 'tibble' was built under R version 4.0.5
## Warning: package 'readr' was built under R version 4.0.5
## Warning: package 'dplyr' was built under R version 4.0.5
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(here)
## here() starts at C:/Users/20120252/Dropbox (Personal)/Statistics/Projects/Project - Foxes
library(ggmap)
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
library(ggplot2)
library(lubridate)
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
library(dismo) #for gmap function
## Loading required package: raster
## Warning: package 'raster' was built under R version 4.0.5
## Loading required package: sp
##
## Attaching package: 'raster'
## The following object is masked from 'package:dplyr':
##
## select
## The following object is masked from 'package:tidyr':
##
## extract
##
## Attaching package: 'dismo'
## The following object is masked from 'package:ggmap':
##
## geocode
library(rgdal) #to work with rasters
## Please note that rgdal will be retired by the end of 2023,
## plan transition to sf/stars/terra functions using GDAL and PROJ
## at your earliest convenience.
##
## rgdal: version: 1.5-27, (SVN revision 1148)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 3.2.1, released 2020/12/29
## Path to GDAL shared files: C:/Users/20120252/OneDrive - Murdoch University/Documents/R/win-library/4.0/rgdal/gdal
## GDAL binary built with GEOS: TRUE
## Loaded PROJ runtime: Rel. 7.2.1, January 1st, 2021, [PJ_VERSION: 721]
## Path to PROJ shared files: C:/Users/20120252/OneDrive - Murdoch University/Documents/R/win-library/4.0/rgdal/proj
## PROJ CDN enabled: FALSE
## Linking to sp version:1.4-5
## To mute warnings of possible GDAL/OSR exportToProj4() degradation,
## use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
## Overwritten PROJ_LIB was C:/Users/20120252/OneDrive - Murdoch University/Documents/R/win-library/4.0/rgdal/proj
library(tlocoh)
## T-LoCoH for R (version 1.40.07)
## URL: http://tlocoh.r-forge.r-project.org/
## Bug reports: tlocoh@gmail.com
library(sp)
Load this if already have work in progress… Note - make sure to update the name of this file if saving a more recent workspace
#load(here("Foxes_tlocoh_fullscript.221121"))
dataorig <- read_csv(here("./data/Tracking_foxes.csv"))
## Rows: 11507 Columns: 21
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (4): ANIMALID, DAY, DATEonly, DATETIME
## dbl (15): sighting, Fix_status, Activity, Temperature, Block, LATITUDE, LON...
## dttm (1): DATETIMEmove
## time (1): TIMEonly
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
str(dataorig)
## spec_tbl_df [11,507 x 21] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ ANIMALID : chr [1:11507] "DB" "DB" "DB" "DB" ...
## $ sighting : num [1:11507] 1 2 3 4 5 7 8 9 10 11 ...
## $ Fix_status : num [1:11507] 2 2 2 2 2 2 2 2 2 2 ...
## $ Activity : num [1:11507] 2 2 5 6 1 0 0 0 0 0 ...
## $ Temperature : num [1:11507] 12 10 14 14 18 20 21 18 19 20 ...
## $ Block : num [1:11507] 1 2 3 4 5 7 8 9 10 11 ...
## $ LATITUDE : num [1:11507] -31.9 -31.9 -31.9 -31.9 -31.9 ...
## $ LONGITUDE : num [1:11507] 116 116 116 116 116 ...
## $ LAT : num [1:11507] 6470560 6470579 6470583 6470109 6470091 ...
## $ LONG : num [1:11507] 392511 392500 392497 392775 392766 ...
## $ NA1 : num [1:11507] 20 22 22 7 10 18 0 0 67 48 ...
## $ NA2 : num [1:11507] 0 0 0 0 0 0 0 0 0 0 ...
## $ HDOP : num [1:11507] 1.9 1.2 1.4 1.2 1.6 1 1.3 1.4 1.2 1.4 ...
## $ NumSats : num [1:11507] 4 7 7 7 7 8 5 5 6 5 ...
## $ FixTime : num [1:11507] 65 32 51 14 81 36 41 14 69 14 ...
## $ 2D_3D : num [1:11507] 3 3 3 3 3 3 3 3 3 3 ...
## $ DAY : chr [1:11507] "8/07/2016 7:00" "8/07/2016 7:30" "8/07/2016 8:00" "8/07/2016 9:00" ...
## $ DATEonly : chr [1:11507] "8/07/2016" "8/07/2016" "8/07/2016" "8/07/2016" ...
## $ TIMEonly : 'hms' num [1:11507] 07:00:00 07:30:00 08:00:00 09:00:00 ...
## ..- attr(*, "units")= chr "secs"
## $ DATETIME : chr [1:11507] "8/07/2016 7:00" "8/07/2016 7:30" "8/07/2016 8:00" "8/07/2016 9:00" ...
## $ DATETIMEmove: POSIXct[1:11507], format: "2016-07-08 07:00:00" "2016-07-08 07:30:00" ...
## - attr(*, "spec")=
## .. cols(
## .. ANIMALID = col_character(),
## .. sighting = col_double(),
## .. Fix_status = col_double(),
## .. Activity = col_double(),
## .. Temperature = col_double(),
## .. Block = col_double(),
## .. LATITUDE = col_double(),
## .. LONGITUDE = col_double(),
## .. LAT = col_double(),
## .. LONG = col_double(),
## .. NA1 = col_double(),
## .. NA2 = col_double(),
## .. HDOP = col_double(),
## .. NumSats = col_double(),
## .. FixTime = col_double(),
## .. `2D_3D` = col_double(),
## .. DAY = col_character(),
## .. DATEonly = col_character(),
## .. TIMEonly = col_time(format = ""),
## .. DATETIME = col_character(),
## .. DATETIMEmove = col_datetime(format = "")
## .. )
## - attr(*, "problems")=<externalptr>
#Check for duplicate locations in dataset
summary(duplicated(dataorig))
## Mode FALSE
## logical 11507
#make sure the data are ordered correctly by tag and date
#Sort data by ID and then datetime to make sure all data grouped together and
#in correct order (to address error in code if needed)
dataorig <- dataorig[order(dataorig$ANIMALID,dataorig$DATETIMEmove),]
##Subset out all the individuals
fox.cc <- dataorig %>% filter(ANIMALID == "CC")
fox.db <- dataorig %>% filter(ANIMALID == "DB")
fox.es <- dataorig %>% filter(ANIMALID == "ES")
fox.fj <- dataorig %>% filter(ANIMALID == "FJ")
fox.hx <- dataorig %>% filter(ANIMALID == "HX")
## FOX - CC - Working of the ‘k’ method
As far as I’m aware the time data is already in local time so no transformation required
#fox.cc$dt <- as.POSIXct(strptime(fox.cc$DATETIME, format="%d/%m/%Y %H:%M"))
fox.cc$dt <- as.POSIXct(fox.cc$DATETIME, format="%d/%m/%Y %H:%M", tz="Australia/Perth")
cc <- fox.cc[,c("LONGITUDE","LATITUDE","dt","ANIMALID")]
#rename cols
colnames(cc)[1:4] <- c("x","y","dt","id")
#check first 4 lines of the dataframe
cc[1:4,]
give x and y a projection This creates the first of a series of new dataframes that are joined. Pretty clunky way to do it but this is what is required in this program
#sub-df 1 latlong
cc.sp.latlong <- SpatialPoints(cc[ , c("x","y")], proj4string=CRS("+proj=longlat +ellps=WGS84"))
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
cc.sp.utm <- spTransform(cc.sp.latlong, CRS("+proj=utm +south +zone=50 +ellps=WGS84"))
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
cc.mat.utm <- coordinates(cc.sp.utm)
tail(cc.mat.utm)
## x y
## [895,] 391502.5 6472546
## [896,] 391661.9 6472144
## [897,] 391991.0 6471619
## [898,] 392107.3 6471759
## [899,] 392223.2 6471721
## [900,] 392276.3 6472169
#sub-df 2 local time - the data are already in this so just subset to follow naming format
cc.local <- as.POSIXct(cc$dt, tz="Australia/Perth")
local.tz <- "Australia/Perth"
cc.localtime <- as.POSIXct(format(cc.local, tz=local.tz), tz=local.tz)
#sub-df 3 id
cc.id <- cc[,c("id")]
#merge all the df in the correct tlocoh format and order
cc.lxy <- xyt.lxy(xy=cc.mat.utm, dt=cc.localtime, id="cc", proj4string=CRS("+proj=utm +south +zone=50 +ellps=WGS84"))#, dup.dt.check=FALSE)
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
Explore the structure of the lxy object
nrow(cc.lxy$pts)
## [1] 900
summary(cc.lxy)
## Summary of LoCoH-xy object: cc.lxy
## ***Locations
## id num.pts dups
## cc 900 3
## ***Time span
## id begin end period
## cc 2016-06-04 2016-08-02 58.8 days
## ***Spatial extent
## x: 391251.3 - 394058.5
## y: 6469647.1 - 6472684.7
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## cc 1800 (30min) 114.9905 1.230966
## ***Ancilliary Variables:
## -none-
## ***Nearest-neighbor set(s):
## none saved
Plot out the movement trajectory
plot(cc.lxy)
Display the distribution of locations by date, step length, and sampling interval.
hist(cc.lxy)
Review the sampling frequency
lxy.plot.freq(cc.lxy, cp=T)
Construct a model of space-use without considering time (s=0). k=25 means that it is considering the nearest 25 points to the parent point (at this stage its completely arbitrary). As we are not considering time these points are the nearest in space and as such may not necessarily be sequential.
cc.lxy <- lxy.nn.add(cc.lxy, s=0, k=25)
## Finding nearest neighbors for id=cc (n=900), num.parent.pts=900,
## mode=Fixed-k, k=25, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: cc|vmax|s0|n900|kmax25|rmax7.8|amax113.1
##
## Done. Nearest neighbor set(s) created / updated:
## cc|vmax|s0|n900|kmax25|rmax7.8|amax113.1
## Total time: 0 secs
summary(cc.lxy)
## Summary of LoCoH-xy object: cc.lxy
## ***Locations
## id num.pts dups
## cc 900 3
## ***Time span
## id begin end period
## cc 2016-06-04 2016-08-02 58.8 days
## ***Spatial extent
## x: 391251.3 - 394058.5
## y: 6469647.1 - 6472684.7
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## cc 1800 (30min) 114.9905 1.230966
## ***Ancilliary Variables:
## -none-
## ***Nearest-neighbor set(s):
## 1 cc|vmax|s0|n900|kmax25|rmax7.8|amax113.1
Save the lxy object for later analysis (when look at the time stuff)
lxy.save(cc.lxy, dir="../data")
## LoCoH-xy cc.lxy saved as cc.lxy to:
## C:\Users\20120252\Dropbox (Personal)\Statistics\Projects\Project - Foxes\data\cc.n900.2016-06-04.2016-08-02.lxy.14.RData
Make a kml to visualise the track on GoogleEarth so can get a feel for the animals movement. This is easy but produces a pretty awful result. Doesn’t appear to read the dt appropriately.
Check out the t-locoh extension tutorial to see if there is a better way to do this.
#lxy.exp.kml(cc.lxy, 'cc.lxy.151121.kml',compress = FALSE, pt.scale = 0.25, path.lwd = 3)
The building blocks of all T-LoCoH analyses are hulls, which are simply minimum convex polygons constructed around each point from a set of nearest neighbors. Since we’ve already identified 25 nearest neighbors for each point, we can create hulls with up to 25 nearest neighbors each. We will use the tlocoh::lxy.lhs command to create an lhs object, the next in our progression.
cc.lhs <- lxy.lhs(cc.lxy, k=3*3:8, s=0)
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## cc: 3 duplicate points were randomly displaced by 1 map unit(s)
##
## cc.pts900.k9.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## cc.pts900.k12.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## cc.pts900.k15.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## cc.pts900.k18.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## cc.pts900.k21.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## cc.pts900.k24.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## The following hullsets were generated:
## cc.pts900.k9.s0.kmin0
## cc.pts900.k12.s0.kmin0
## cc.pts900.k15.s0.kmin0
## cc.pts900.k18.s0.kmin0
## cc.pts900.k21.s0.kmin0
## cc.pts900.k24.s0.kmin0
## Total time: 1.5 secs
What we are doing here is creating 6 different hullsets with k values of 9, 12, 15, 18, 21, and 24 (note we are still setting s=0 because we are not considering the temporal component yet). It is useful to create a selection of hullsets so that we can compare them and choose the optimal one for our purposes. The downside of creating all of these extra hullsets is that it may take a little while to run. Once it is finished, we can get an idea of what areas are included in our hullsets using the tlocoh::plot command again. This time, we will specify that we want to plot the hulls and we’ll add all of the plots to a single page for easier comparison.
plot(cc.lhs, hulls=TRUE, figs.per.page=6)
Isopleths are aggregations of hulls sorted in such a way as to reveal something about space use. The default settings for tlocoh::lhs.iso.add sorts hulls according to density, so the isopleths reflect the likelihood of occurrence, which is a proxy for intensity of use. Then we can plot these (using the iso=TRUE specification instead of hulls=TRUE) to see how they compare to one another and to the hullset plots.
cc.lhs <- lhs.iso.add(cc.lhs)
## Merging hulls into isopleths
## cc.pts900.k9.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 391797.78442823997 6472331.5370918196
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## cc.pts900.k12.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 391627.14367159997 6471653.1214472996
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 392237.94388516003 6472260.4636869701
## grps.cum.union.lst[[i - 1]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## 1 invalid polygon(s) removed
## cc.pts900.k15.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.k18.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## 1 invalid polygon(s) removed
## cc.pts900.k21.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 391686.94317823002 6472390.3494679304
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## cc.pts900.k24.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 391865.62996425998 6472120.5110683804
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## Total time: 0.6 secs
plot(cc.lhs, iso=TRUE, figs.per.page=6)
plot(cc.lhs, iso=T, k=15, allpts=T, cex.allpts=0.1, col.allpts="gray90", ufipt=F)
Note: you can also produce the above plot without the pts. In this case just use: plot(cc.lhs, iso=T, k=15, ufipt=F)
Two other plots can be used to evaluate the choice of k value. The first is the isopleth area curves, which will plot the area included in a set of different isopleth levels (ranging from 0.15 to 0.95 by 0.10). We want to check these plots to make sure that there are no sharp jumps between k values that indicate that a relatively small change in k results in a large increase in included area (likely a false commission). To look at this plot, we use the tlocoh::lhs.plot.isoarea command:
lhs.plot.isoarea(cc.lhs)
There don’t appear to be any major jump (i.e., the curves are all resonably smooth, no matter the k value). This means we shouldn’t rule out any of the k values we have tested.
Next - look at the edge to area ratio. We are looking to exclude k values that result in very high edge:area ratios, which are indicative of the Swiss cheese pattern (i.e., many small holes). This is particularly important at some of the isopleths associated with the core area (0.35, 0.45, 0.55) where we would expect relatively few holes.
lhs.plot.isoear(cc.lhs)
If the plots are too small in the RMarkdown window then put the code into the Console and view the plot in the plot window. Resize this area first so that the plot is nice and big. Having run all the k values multiple time k=15 is actually the best. i.e. using a larger value of k doesnt really change how many of the grey dtps are included in the hulls.
Select this value for subsequent runs and save as an object
cc.lhs.k15 <- lhs.select(cc.lhs, k=15)
lhs.save(cc.lhs.k15, dir="../data")
## LoCoH-hullset cc.lhs.k15 saved as 'cc.lhs.k15' to:
## C:\Users\20120252\Dropbox (Personal)\Statistics\Projects\Project - Foxes\data\cc.n900.s0.k15.iso.lhs.11.RData
If doing this step in another session then you need to load the lxy and lhs RData files that you saved above. Use the following syntax:
load(‘./data/cc.n900.2016-06-04.2016-08-02.lxy.02.RData’) load(‘./data/cc.n900.s0.k15.iso.lhs.02.RData’)
create a new nearest neighbor set with a non-zero s parameter. That is, we are now creating a UD that incorporates time. In the first plot there are points in the same general areas that are colour coded differently. This means that they were in the same area but at different times so these points are not temporally related. In the s=0 calculations above this is ignored and therefore is not ecologically very informative.
Firstly, need to select a ‘decent’ s value. To do this pick an s value such that 40-80% of the hulls are ‘time-selected.’
This is Method 1
cc.lxy <- lxy.ptsh.add(cc.lxy)
## id: cc
## Randomly selected 200 of 900 points
## Finding 10 nearest neighbors for 200 sample points
## Finding s for ptsh=0.98
## s=0.005, s=0.01, s=0.02, s=0.04, s=0.08, s=0.16,
## Finding s for ptsh=0.1 (+/- 0.01)
## s=0.0025, s=0.00125, s=0.001875, s=0.0015625, s=0.00140625,
## Finding s for ptsh=0.2 (+/- 0.01)
## s=0.00375, s=0.003125, s=0.0028125,
## Finding s for ptsh=0.3 (+/- 0.01)
## s=0.015, s=0.0125, s=0.01375,
## Finding s for ptsh=0.4 (+/- 0.01)
## Finding s for ptsh=0.5 (+/- 0.01)
## s=0.03, s=0.025,
## Finding s for ptsh=0.6 (+/- 0.01)
## s=0.0275, s=0.02875,
## Finding s for ptsh=0.7 (+/- 0.01)
## s=0.035, s=0.0375,
## Finding s for ptsh=0.8 (+/- 0.01)
## s=0.06, s=0.05,
## Finding s for ptsh=0.9 (+/- 0.01)
## s=0.07, s=0.065,
##
## Done with cc
This creates a set of 200 sample points, each with 10 nearest neighbors. This algorithm goes through a set of different s values and determines what proportion of hulls are time-selected (ptsh). Though this is a somewhat stochastic process, we can see that s values between approximately 0.0175 and 0.04 fall between proportions of time-selected hulls ranging from about 40-80%. Its more easily understood just by looking at the plot.
Method 2 Select a time interval that is ecologically relevant. We are interested in daily movement (e.g. night time foraging), so a 24hr cycle is OK - on the premise that points that are close together but more than 24hrs apart are not related. If you are thinking about longer temporal patterns (e.g. season), then you need to adjust the value accordingly. If you dont have a clue and are fishing for patterns then do this:
lxy.plot.pt2ctr(cc.lxy)
and then do this:
lxy.plot.sfinder(cc.lxy)
then do this:
#note: 3600 = 1 hour (3600 seconds)
lxy.plot.sfinder(cc.lxy, delta.t=3600*c(12,24,36,48,54,60))
Both methods support an s=0.03 value at the scale of 24hrs. According to the manual these methods don’t necessarily always converge. Apparently that is not an issue as the methods are extremely different.
using s= 0.3 and retaining k = 25 (value used in the distance only method)
cc.lxy <- lxy.nn.add(cc.lxy, s=0.03, k=25)
## Finding nearest neighbors for id=cc (n=900), num.parent.pts=900,
## mode=Fixed-k, k=25, s=0.03, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: cc|vmax|s0.03|n900|kmax25|rmax907|amax12763.1
##
## Done. Nearest neighbor set(s) created / updated:
## cc|vmax|s0.03|n900|kmax25|rmax907|amax12763.1
## Total time: 1.3 secs
this adds another NN set to cc.lxy ie it includes it as another list. To view:
summary(cc.lxy)
## Summary of LoCoH-xy object: cc.lxy
## ***Locations
## id num.pts dups
## cc 900 3
## ***Time span
## id begin end period
## cc 2016-06-04 2016-08-02 58.8 days
## ***Spatial extent
## x: 391251.3 - 394058.5
## y: 6469647.1 - 6472684.7
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## cc 1800 (30min) 114.9905 1.230966
## ***Ancilliary Variables:
## -none-
## ***ptsh s-values computed
## id k n ptsh
## cc 10 200 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98
## ***Nearest-neighbor set(s):
## 1 cc|vmax|s0|n900|kmax25|rmax7.8|amax113.1
## 2 cc|vmax|s0.03|n900|kmax25|rmax907|amax12763.1
Note the huge difference in the rmax and amax values (perhaps better to use these methods than fixed k)
Can also calculate s in the same way that calculated k. This next section follows the method to do this. I don’t think its necessary as we have already used a decent method above but I will run through this method just to see if the choice is the same.
cc.lxy <- lxy.nn.add(cc.lxy, s=c(0.0003, 0.003, 0.03, 0.3), k=25)
## Finding nearest neighbors for id=cc (n=900), num.parent.pts=900,
## mode=Fixed-k, k=25, s=3e-04, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: cc|vmax|s3e-04|n900|kmax25|rmax34|amax588.6
## Finding nearest neighbors for id=cc (n=900), num.parent.pts=900,
## mode=Fixed-k, k=25, s=0.003, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: cc|vmax|s0.003|n900|kmax25|rmax173.5|amax2669.2
## Finding nearest neighbors for id=cc (n=900), num.parent.pts=900,
## mode=Fixed-k, k=25, s=0.03, method=TSD:vmax
## - there is already a set of nearest neighbors for this set of parent
## points and value of s.
## - enough points already saved, no need to find more
## Finding nearest neighbors for id=cc (n=900), num.parent.pts=900,
## mode=Fixed-k, k=25, s=0.3, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: cc|vmax|s0.3|n900|kmax25|rmax8642.8|amax112506.8
##
## Done. Nearest neighbor set(s) created / updated:
## cc|vmax|s3e-04|n900|kmax25|rmax34|amax588.6
## cc|vmax|s0.003|n900|kmax25|rmax173.5|amax2669.2
## cc|vmax|s0.3|n900|kmax25|rmax8642.8|amax112506.8
## Total time: 3.6 secs
lxy.plot.mtdr(cc.lxy, k=10)
## Computing maximum theoretical distance over TSD for cc
##
|
| | 0%
|
|============== | 20%
|
|============================ | 40%
|
|========================================== | 60%
|
|======================================================== | 80%
|
|======================================================================| 100%
lxy.plot.tspan(cc.lxy, k=10)
## Computing time span for cc
##
|
| | 0%
|
|============== | 20%
|
|============================ | 40%
|
|========================================== | 60%
|
|======================================================== | 80%
|
|======================================================================| 100%
Comment from the tutorial “These methods still leave a great deal up to the researcher, which has its pros and cons, but at least you’ve got quite a few alternatives for selecting an ideal s value for your particular purposes”. We’ll stick with our 0.03 value for now, but we’ll need to create a new lhs object using this parameter:
cc.lhs.time <- lxy.lhs(cc.lxy, k=3*3:8, s=0.03)
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## cc: 3 duplicate points were randomly displaced by 1 map unit(s)
##
## cc.pts900.k9.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## cc.pts900.k12.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## cc.pts900.k15.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## cc.pts900.k18.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## cc.pts900.k21.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## cc.pts900.k24.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## The following hullsets were generated:
## cc.pts900.k9.s0.03.kmin0
## cc.pts900.k12.s0.03.kmin0
## cc.pts900.k15.s0.03.kmin0
## cc.pts900.k18.s0.03.kmin0
## cc.pts900.k21.s0.03.kmin0
## cc.pts900.k24.s0.03.kmin0
## Total time: 2.6 secs
Merge the hulls into isopleths
cc.lhs.time <- lhs.iso.add(cc.lhs.time)
## Merging hulls into isopleths
## cc.pts900.k9.s0.03.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.k12.s0.03.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.k15.s0.03.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.k18.s0.03.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.k21.s0.03.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.k24.s0.03.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Total time: 0.3 secs
Plot the isopleths
plot(cc.lhs.time, iso=TRUE, figs.per.page=6)
When I was going through these in R I changed the figs.per.page to =1 as its too hard to see things on the screen. I’m not entirely sure that k=15 is the best but it is better than the other k’s. I think maybe it might be a good idea to play with the other parameters r and a.
Compare the with time version to the original distance only method
cc.lhs.time.k15 <- lhs.select(cc.lhs.time, k=15)
plot(cc.lhs.k15, iso=TRUE, figs.per.page=1)
plot(cc.lhs.time.k15, iso=TRUE, figs.per.page=1)
Save the time selected hullset to use with additional work if taking a break at this point.
lhs.save(cc.lhs.time.k15, dir="../data")
## LoCoH-hullset cc.lhs.time.k15 saved as 'cc.lhs.time.k15' to:
## C:\Users\20120252\Dropbox (Personal)\Statistics\Projects\Project - Foxes\data\cc.n900.s0.03.k15.iso.lhs.08.RData
cc.isos <- isopleths(cc.lhs.k15)
cc.isos[[1]]@data
cc.time.isos <- isopleths(cc.lhs.time.k15)
cc.time.isos[[1]]@data
cc.core <- cc.isos[[1]][ cc.isos[[1]][["iso.level"]]==0.5, ]
cc.hr <- cc.isos[[1]][ cc.isos[[1]][["iso.level"]]==0.95, ]
plot(cc.hr, border="blue")
plot(cc.core, border="red", add=T)
cc.time.isos <- isopleths(cc.lhs.time.k15) cc.time.isos[[1]]@data
Plot calculation of area|time vis
cc.time.core <- cc.time.isos[[1]][ cc.time.isos[[1]][["iso.level"]]==0.5, ]
cc.time.hr <- cc.time.isos[[1]][ cc.time.isos[[1]][["iso.level"]]==0.95, ]
plot(cc.time.hr, border="blue")
plot(cc.time.core, border="red", add=T)
see p20 in the tlocoh_tutorial.pdf (in the help file)
Reasoning for using it: The ‘a’ in a-method stands for adaptive, because this method is designed to reduce the number of neighbors used in areas where the points are thin and scattered. Neighbors are identified by summing up their cumulative distance from the parent point and stopping when you reach a. This may result in a many points being labeled as neighbors in a dense area (which is what you probably want), and just a few points in outlying areas (which is also what you want).
The workflow is the same as the k method, BUT deciding on a value of ‘a’ is not straightforward because: 1) a is a cumulative distance from the parent point to the nearest neighbors 2) if time is included, the ‘distance’ between points is the TSD space-time metric which is not a physical distance.
To assist in picking an appropriate value of ‘a’ the auto.a function is used. This computes the ‘a’ value such that p% of points get at least n nearest neighbours, where p and n are supplied by you.
So for example, if we like the results with k=15, we can use auto.a() to tell us the value of ‘a’ that will result in 98% of all points having 15 or more nearest neighbours.
cc.a.lxy <- lxy.nn.add(cc.lxy, s=0.03, a=auto.a(nnn=15, ptp=0.98))
## Finding nearest neighbors for id=cc (n=900), num.parent.pts=900,
## mode=Auto-a, auto.a=nn|0.98|15|1.05, s=0.03, method=TSD:vmax
## - there is already a set of nearest neighbors for this set of parent
## points and value of s.
## - additional neighbors will be identified and appended as needed
## - computing auto-a...
## - found from existing NN set. Auto-a is 18281.8
## - finding an initial value of k using 30 randomly selected points...Done.
## - Initial k=26
## - computing cumulative distances for k=26
## - 26 wasn't large enough for 232 points. Computing cumulative
## distances for k=52 points
## - 6385 additional neighbors appended
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: cc|vmax|s0.03|n900|kmax25|rmax1010.9|amax18286.1
##
## Done. Nearest neighbor set(s) created / updated:
## cc|vmax|s0.03|n900|kmax25|rmax1010.9|amax18286.1
## Total time: 1.1 secs
summary(cc.a.lxy)
## Summary of LoCoH-xy object: cc.a.lxy
## ***Locations
## id num.pts dups
## cc 900 3
## ***Time span
## id begin end period
## cc 2016-06-04 2016-08-02 58.8 days
## ***Spatial extent
## x: 391251.3 - 394058.5
## y: 6469647.1 - 6472684.7
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## cc 1800 (30min) 114.9905 1.230966
## ***Ancilliary Variables:
## -none-
## ***ptsh s-values computed
## id k n ptsh
## cc 10 200 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98
## ***Nearest-neighbor set(s):
## 1 cc|vmax|s0|n900|kmax25|rmax7.8|amax113.1
## 2 cc|vmax|s3e-04|n900|kmax25|rmax34|amax588.6
## 3 cc|vmax|s0.003|n900|kmax25|rmax173.5|amax2669.2
## 5 cc|vmax|s0.03|n900|kmax25|rmax1010.9|amax18286.1
## meth ptp nnn tct aVal
## auto.a #1 nn 0.98 15 1.05 18281.8
## 4 cc|vmax|s0.3|n900|kmax25|rmax8642.8|amax112506.8
This summary output tells us that for s= 0.03, if a = 18286.1, that 98% of pts will have at least 15 nn.
You can now use this to set the range of a values to test to calculate the hullsets. For example: could test a = 10000, 11000, ……20000, then view the isopleth plots to see if happy or whether still need to fine tune things. This is really subjective, but this is actually how its done.
cc.a.lxy <- lxy.nn.add(cc.a.lxy, s=0.03, a=21000)
## Finding nearest neighbors for id=cc (n=900), num.parent.pts=900,
## mode=Fixed-a, a=21000, s=0.03, method=TSD:vmax
## - there is already a set of nearest neighbors for this set of parent
## points and value of s.
## - additional neighbors will be identified and appended as needed
## - finding an initial value of k using 30 randomly selected points...Done.
## - Initial k=30
## - computing cumulative distances for k=30
## - 1509 additional neighbors appended
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: cc|vmax|s0.03|n900|kmax25|rmax1109.4|amax21014.6
##
## Done. Nearest neighbor set(s) created / updated:
## cc|vmax|s0.03|n900|kmax25|rmax1109.4|amax21014.6
## Total time: 0.7 secs
summary(cc.a.lxy)
## Summary of LoCoH-xy object: cc.a.lxy
## ***Locations
## id num.pts dups
## cc 900 3
## ***Time span
## id begin end period
## cc 2016-06-04 2016-08-02 58.8 days
## ***Spatial extent
## x: 391251.3 - 394058.5
## y: 6469647.1 - 6472684.7
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## cc 1800 (30min) 114.9905 1.230966
## ***Ancilliary Variables:
## -none-
## ***ptsh s-values computed
## id k n ptsh
## cc 10 200 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98
## ***Nearest-neighbor set(s):
## 1 cc|vmax|s0|n900|kmax25|rmax7.8|amax113.1
## 2 cc|vmax|s3e-04|n900|kmax25|rmax34|amax588.6
## 3 cc|vmax|s0.003|n900|kmax25|rmax173.5|amax2669.2
## 5 cc|vmax|s0.03|n900|kmax25|rmax1109.4|amax21014.6
## meth ptp nnn tct aVal
## auto.a #1 nn 0.98 15 1.05 18281.8
## 4 cc|vmax|s0.3|n900|kmax25|rmax8642.8|amax112506.8
At this point also add the isopleths; previously we did this as a seperate step
cc.lhs.amixed <- lxy.lhs(cc.a.lxy, s=0.03, a=4:20*1000, iso.add=T)
## Using nearest-neighbor selection mode: Fixed-a
## Constructing hulls and hull metrics...
## cc: 3 duplicate points were randomly displaced by 1 map unit(s)
##
## cc.pts900.a4000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a5000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a6000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a7000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a8000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a9000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a10000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a11000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a12000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a13000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a14000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a15000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a16000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a17000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a18000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a19000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## cc.pts900.a20000.s0.03.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
## The following hullsets were generated:
## cc.pts900.a4000.s0.03.kmin0
## cc.pts900.a5000.s0.03.kmin0
## cc.pts900.a6000.s0.03.kmin0
## cc.pts900.a7000.s0.03.kmin0
## cc.pts900.a8000.s0.03.kmin0
## cc.pts900.a9000.s0.03.kmin0
## cc.pts900.a10000.s0.03.kmin0
## cc.pts900.a11000.s0.03.kmin0
## cc.pts900.a12000.s0.03.kmin0
## cc.pts900.a13000.s0.03.kmin0
## cc.pts900.a14000.s0.03.kmin0
## cc.pts900.a15000.s0.03.kmin0
## cc.pts900.a16000.s0.03.kmin0
## cc.pts900.a17000.s0.03.kmin0
## cc.pts900.a18000.s0.03.kmin0
## cc.pts900.a19000.s0.03.kmin0
## cc.pts900.a20000.s0.03.kmin0
## Total time: 8 secs
plot(cc.lhs.amixed, hulls=TRUE,figs.per.page=6)
plot(cc.lhs.amixed, iso=TRUE, figs.per.page=6)
to try an help with interpreting the which value of a is reasonable
lhs.plot.isoarea(cc.lhs.amixed)
lhs.plot.isoear(cc.lhs.amixed)
This suggests that a= 15000 is pretty good
plot(cc.lhs.amixed, hulls=T, a=15000, allpts=T, cex.allpts=0.1, col.allpts="gray10", ufipt=F)
plot(cc.lhs.amixed, iso=T, a=15000, allpts=T, cex.allpts=0.1, col.allpts="gray10", ufipt=F)
# calculation of area|time|a method
cc.timea.isos <- isopleths(cc.lhs.amixed, a=20000)
cc.timea.isos[[1]]@data
The previous time fixed k method gave 50% as 26ha, 95% as 78ha Here we have 32ha and 96ha
Calculation of area|time|a method with pts overlay
cc.timea.core <- cc.timea.isos[[1]][ cc.timea.isos[[1]][["iso.level"]]==0.5, ]
cc.timea.hr <- cc.timea.isos[[1]][ cc.timea.isos[[1]][["iso.level"]]==0.95, ]
plot(cc.timea.hr, border="blue")
plot(cc.timea.core, border="red", add=T)
plot(cc.lhs.amixed,a=15000, allpts=T, cex.allpts=0.1, col.allpts="gray10", ufipt=F, add=T)
Generate the eccentricity of the bounding ellipsoids. This is used as a proxy of elongation or directionality
cc.lhs.amixed <- lhs.ellipses.add(cc.lhs.amixed)
## cc.pts900.a4000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a5000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a6000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a7000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a8000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a9000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a10000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a11000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a12000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a13000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a14000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a15000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a16000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a17000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a18000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a19000.s0.03.kmin0
## Calculating enclosing ellipses
## cc.pts900.a20000.s0.03.kmin0
## Calculating enclosing ellipses
## Total time: 3 mins
plot(cc.lhs.amixed, ellipses=T,figs.per.page=1)
Remember that according to the previous analysis that a=15000 is the plot that is most reasonable
summary(cc.lhs.amixed)
## Summary of LoCoH-hullset object: cc.lhs.amixed
## Created by: T-LoCoH 1.40.7
## [1] cc.pts900.a4000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=4000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:23 2021
##
## [2] cc.pts900.a5000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=5000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:24 2021
##
## [3] cc.pts900.a6000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=6000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:24 2021
##
## [4] cc.pts900.a7000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=7000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:25 2021
##
## [5] cc.pts900.a8000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=8000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:25 2021
##
## [6] cc.pts900.a9000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=9000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:25 2021
##
## [7] cc.pts900.a10000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=10000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:26 2021
##
## [8] cc.pts900.a11000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=11000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:26 2021
##
## [9] cc.pts900.a12000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=12000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:27 2021
##
## [10] cc.pts900.a13000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=13000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:27 2021
##
## [11] cc.pts900.a14000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=14000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:28 2021
##
## [12] cc.pts900.a15000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=15000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:28 2021
##
## [13] cc.pts900.a16000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=16000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:29 2021
##
## [14] cc.pts900.a17000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=17000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:29 2021
##
## [15] cc.pts900.a18000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=18000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:30 2021
##
## [16] cc.pts900.a19000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=19000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:30 2021
##
## [17] cc.pts900.a20000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=20000, kmin=0, s=0.03
## metrics: area, ecc, nep, nnn, perim, scg.enc.mean, scg.enc.sd,
## scg.nn.mean, scg.nn.sd, tspan
## isos: [1] iso.srt-nep.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:31 2021
cc.lhs.amixed <- lhs.iso.add(cc.lhs.amixed, sort.metric="ecc")
## Merging hulls into isopleths
## cc.pts900.a4000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a5000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a6000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a7000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a8000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a9000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a10000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a11000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a12000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a13000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a14000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a15000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a16000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a17000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a18000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a19000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## cc.pts900.a20000.s0.03.kmin0
## Sorting hulls by ecc descending...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Total time: 0.4 secs
plot(cc.lhs.amixed, iso=T, iso.sort.metric="ecc")
plot(cc.lhs.amixed, a=15000, iso=T, iso.sort.metric="ecc") #just the a=15000 hullset
What this shows are the areas where cc was doing more directed movement - the red areas.
Revisitation - to each hull - the number of pts in the hull basically Duration - to the hull - the amount of time spent in the hull
For example: Long duration might represent the importance of seasonal resources; High revisitation rates may represent permanently available resources. But, high revisitation and short duration may represent daily (or twice daily) trips to a water hole. What would a den look like then? ……..would be inside core area…high revisitation and long duration?
We need to set a reasonable ‘inter visit gap’ (IVG). We are interested in a daily cycle (24hrs), but so as not to lose behaviour that is 23hrs apart set the IVG at 12hrs. This is done in seconds.
cc.lhs.amixed <- lhs.visit.add(cc.lhs.amixed, ivg=3600*12)
## cc.pts900.a4000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a5000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a6000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a7000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a8000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a9000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a10000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a11000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a12000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a13000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a14000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a15000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a16000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a17000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a18000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a19000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
## cc.pts900.a20000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=43200 (12hs)
summary(cc.lhs.amixed)
## Summary of LoCoH-hullset object: cc.lhs.amixed
## Created by: T-LoCoH 1.40.7
## [1] cc.pts900.a4000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=4000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:23 2021
##
## [2] cc.pts900.a5000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=5000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:24 2021
##
## [3] cc.pts900.a6000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=6000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:24 2021
##
## [4] cc.pts900.a7000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=7000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:25 2021
##
## [5] cc.pts900.a8000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=8000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:25 2021
##
## [6] cc.pts900.a9000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=9000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:25 2021
##
## [7] cc.pts900.a10000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=10000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:26 2021
##
## [8] cc.pts900.a11000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=11000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:26 2021
##
## [9] cc.pts900.a12000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=12000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:27 2021
##
## [10] cc.pts900.a13000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=13000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:27 2021
##
## [11] cc.pts900.a14000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=14000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:28 2021
##
## [12] cc.pts900.a15000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=15000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:28 2021
##
## [13] cc.pts900.a16000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=16000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:29 2021
##
## [14] cc.pts900.a17000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=17000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:29 2021
##
## [15] cc.pts900.a18000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=18000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:30 2021
##
## [16] cc.pts900.a19000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=19000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:30 2021
##
## [17] cc.pts900.a20000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=20000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, nep, nnn, nsv.43200, perim,
## scg.enc.mean, scg.enc.sd, scg.nn.mean, scg.nn.sd, tspan
## hmap: ivg (43200)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:31 2021
nsv.43200 = the measure of revisitation and stands for number of separate visits for an inter-visit gap period of 43200 seconds.
mnlv.43200 = mean number of locations per visit, and is the measure of average duration.
lhs.save(cc.lhs.amixed) #nb. I move this RData file to the data folder manually
## LoCoH-hullset cc.lhs.amixed saved as 'cc.lhs.amixed' to:
## C:\Users\20120252\Dropbox (Personal)\Statistics\Projects\Project - Foxes\scripts\cc.n900.s0.03.a4000-x15-20000.elps.iso.lhs.05.RData
Next look at the various hull metrics
hist(cc.lhs.amixed, a=15000, metric="nsv")
nb. there is a missing hull as 1pt is not included in the hull metric calculation i.e. it didnt fit the criteria for inclusion.
Basically this says that the majority of hulls were visited at a pretty high rate
To see what this looks like in real space plot the points:
plot(cc.lhs.amixed,hpp=T, hpp.classify="nsv", ivg=3600*12, col.ramp="rainbow")
Make a zoomed version. aoi = area of interest. You have to put the plot call into the console and run it so that the plot appears in the ‘PLots’ window and you can select the area of interest by clicking the ‘top left’ and ‘bottom right’ to define the zoom area.
You have to plot the next line from the console window (I have just told it to run a=15000), then run the aoi call: plot(cc.lhs.amixed,hpp=T, hpp.classify=“nsv”, ivg=3600*12, col.ramp=“rainbow”) n.b. this plot all a values, so you have to scroll through until you get the one of interest.
I have commented the line out at L637 as it interferes with the knit. Just uncomment to use
# cc.aoi <- aoi()
#plot(cc.lhs.amixed,hpp=T, hpp.classify="nsv", ivg=3600*12, col.ramp="rainbow", aoi=cc.aoi)
See if this looks much different if use an IVG of 20hrs
cc.lhs.amixed20 <- lhs.visit.add(cc.lhs.amixed, ivg=3600*20)
## cc.pts900.a4000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a5000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a6000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a7000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a8000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a9000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a10000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a11000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a12000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a13000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a14000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a15000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a16000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a17000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a18000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a19000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
## cc.pts900.a20000.s0.03.kmin0
## 1 of 1. Computing the number of visits in each hull for ivg=72000 (20hs)
summary(cc.lhs.amixed20)
## Summary of LoCoH-hullset object: cc.lhs.amixed20
## Created by: T-LoCoH 1.40.7
## [1] cc.pts900.a4000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=4000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:23 2021
##
## [2] cc.pts900.a5000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=5000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:24 2021
##
## [3] cc.pts900.a6000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=6000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:24 2021
##
## [4] cc.pts900.a7000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=7000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:25 2021
##
## [5] cc.pts900.a8000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=8000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:25 2021
##
## [6] cc.pts900.a9000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=9000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:25 2021
##
## [7] cc.pts900.a10000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=10000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:26 2021
##
## [8] cc.pts900.a11000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=11000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:26 2021
##
## [9] cc.pts900.a12000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=12000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:27 2021
##
## [10] cc.pts900.a13000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=13000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:27 2021
##
## [11] cc.pts900.a14000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=14000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:28 2021
##
## [12] cc.pts900.a15000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=15000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:28 2021
##
## [13] cc.pts900.a16000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=16000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:29 2021
##
## [14] cc.pts900.a17000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=17000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:29 2021
##
## [15] cc.pts900.a18000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=18000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:30 2021
##
## [16] cc.pts900.a19000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=19000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:30 2021
##
## [17] cc.pts900.a20000.s0.03.kmin0
## id: cc
## pts: 900
## dates: 2016-06-04 15:00:00 AWST to 2016-08-02 11:00:00 AWST
## movement: tau=1800 (30min), vmax=1.230966, d.bar=114.9905
## hulls: 899
## dups: 3 (offset by 1 map unit)
## mode: a=20000, kmin=0, s=0.03
## metrics: area, ecc, mnlv.43200, mnlv.72000, nep, nnn, nsv.43200,
## nsv.72000, perim, scg.enc.mean, scg.enc.sd, scg.nn.mean,
## scg.nn.sd, tspan
## hmap: ivg (43200, 72000)
## isos: [1] iso.srt-nep.iso-q.h899.i5
## [2] iso.srt-ecc.iso-q.h899.i5
## other: ellipses
## created: Thu Nov 25 19:01:31 2021
hist(cc.lhs.amixed20, a=15000, metric="nsv")
Well thats really interesting. 20hrs is way toooooooo long to. 12 hrs or maybe less(?) is suitable for foxes.
plot(cc.lhs.amixed20,hpp=T, hpp.classify="nsv", ivg=3600*20, col.ramp="rainbow")
Extract out just the a=15000 hullset for the moment as having all the other ones is distracting
cc.lhs.a15000 <- lhs.select(cc.lhs.amixed, a = 15000, status = T)
have a look at what visitation rate is by time of day.
plot(cc.lhs.amixed,hpp=T, hpp.classify=“nsv”, ivg=3600*12, col.ramp=“rainbow”, aoi=cc.aoi)
#plot(cc.lhs.amixed,hpp=T, hpp.classify="nsv", ivg=3600*12, col.ramp="rainbow", aoi=cc.aoi)
Make a zoomed version
Put the next line into the console so that the plot appears in the plot window >plot(cc.lhs.a15000,hpp=T, hpp.classify=“dt.hour”, ivg=3600*12, col.ramp = “rainbow”)
run the next line in the console so that you can select the zoom area >cc.aoi <- aoi()
Then re-run the plot call as usual including the aoi information
#plot(cc.lhs.a15000,hpp=T, hpp.classify="dt.hour", ivg=3600*12, col.ramp = "rainbow", aoi = cc.aoi)
Definitely a time signature here. Would be interesting to play with the IVG and get a better idea of the data to ID ‘dens’ or rest spots.
Though to be honest I think I may prefer recurse for this type of analysis.
Or by month
plot(cc.lhs.a15000,hpp=T, hpp.classify="dt.month", ivg=3600*12, col.ramp = "rainbow")
make a zoomed version of the mass of points
#cc.aoi <- aoi()
#plot(cc.lhs.a15000,hpp=T, hpp.classify="dt.month", ivg=3600*12, col.ramp = "rainbow", aoi = cc.aoi)
Doesnt show anything particularly interesting.
Anyway, can plug in any metric you like from the below list to explore the data.
However, alot of these metrics are calculated on the fly and not saved in the hull metrics file.
There is another pdf that is interesting for hull metric calculations:
https://tlocoh.r-forge.r-project.org/tips/exploring_time_use_metrics.html
To save hull metrics as dataframes that can be used for other things see:
file:///C:/Users/20120252/Dropbox%20(Personal)/Statistics/R%20Vignettes/t-LoCoH/hull-metrics.nb.html This also has instructions about how to calculate various metrics.
These are all the hull metrics available in this hullset (the list will only generate the metrics that have been calculated - so it may not be an exhaustive list)
hm.expr() #use this call in the console Hull Metrics dt date of the parent point dt.month month of the parent point dt.hour hour of the day of the parent point tspan time span of nearest neighbors area area nnn number of nearest neighbors nep number of enclosed points ecc eccentricity of the bounding ellipse, see lhs.ellipses.add par perimeter:area ratio perim perimeter nsv visitation rate (requires ‘ivg’), see lhs.visit.add nnsv normalized visitation rate (requires ‘ivg’), see lhs.visit.add mnlv duration of visit (requires ‘ivg’), see lhs.visit.add nmnlv normalized duration of visit (requires ‘ivg’), see lhs.visit.add nsr revisitation rate (requires ‘ta.min’, ‘ta.max’), see lhs.revisit.add pep proportion of enclosed points (requires ‘pep.var’, ‘pep.val’), see lhs.pep.add pep.mcol proportion of enclosed points, see lhs.pep.add npep proportion of enclosed points normalized by area (requires ‘pep.var’, ‘pep.val’), see lhs.pep.add anv ancillary variable (requires ‘anv’) scg.enc.mean avg speed of enclosed points scg.nn.mean avg speed of nearest neighbors scg.enc.sd stdev of the speed of enclosed points scg.nn.sd stdev of the speed of nearest neighbors so.count number of overlapping hulls (requires ‘hs2’), see lhs.so.add so.dtmin min time diff of overlapping hulls (requires ‘hs2’), see lhs.so.add to.mcd mean centroid distance of temporally overlapping hulls (requires ‘hs2’), see lhs.to.add
hull.tod.scatter <- lhs.plot.scatter(cc.lhs.a15000, x.axis="nsv", y.axis ="dt.hour", col="spiral", bg="black")
hull.tod.scatter
## $nsv.vs.dt.hour.ivg.43200.01
## $hs.name
## [1] "cc.pts900.a15000.s0.03.kmin0"
##
## $x.axis
## [1] "nsv"
##
## $y.axis
## [1] "dt.hour"
##
## $limx
## NULL
##
## $limy
## NULL
##
## $trans.x
## NULL
##
## $trans.y
## NULL
##
## $jiggle.x
## [1] "auto"
##
## $hmap
## $hmap$ivg
## [1] 43200
##
##
## $title
## NULL
##
## $ufat
## [1] TRUE
##
## $bg
## [1] "black"
##
## $cex
## [1] 0.6
##
## $col
## [1] "spiral"
##
## $hue.offset
## NULL
##
## $sat.base
## NULL
##
## $val.base
## NULL
##
## $center.method
## [1] "mean"
##
## $regions
## NULL
##
## $xvals.range
## [1] 3.812615 30.165357
##
## $yvals.range
## [1] -0.08096475 23.13918095
##
## attr(,"class")
## [1] "locoh.hsp"
hist(cc.lhs.a15000, metric= "mnlv")
plot(cc.lhs.a15000, hpp=T, hpp.classify="mnlv", col.ramp="rainbow")
Zoomed version
#plot(cc.lhs.a15000, hpp=T, hpp.classify="mnlv", col.ramp="rainbow", aoi = cc.aoi)
Create a scatterplot of hull revisitation and duration
hsp <- lhs.plot.scatter(cc.lhs.a15000, x="nsv", y="mnlv", col="spiral", bg="black")
plot(cc.lhs.a15000, hpp=T, hsp=hsp, hpp.classify="hsp")
Create a scatterplot of time of day and duration
toddur <- lhs.plot.scatter(cc.lhs.a15000, x="dt.hour", y="mnlv", col="spiral", bg="black")
plot(cc.lhs.a15000, hpp=T, hsp=toddur, hpp.classify="hsp")
You can export all the data from the hull with lhs.exp.csv. Unfortunately this does not export the lat/long information or a bunch of other metrics that are calculated on the fly. Below I have also exported the data as a shapefile which includes this data.
lhs.exp.csv(cc.lhs.a15000, csv.save = T, dir = "../data", hm ="all", status = T)
## ../data/cc.s0.03.a15000.03.csv
Export the data as a shapefile
lhs.exp.shp(cc.lhs.a15000, hpp = T, hulls = T, iso = T, dir = "../tlocohShapefiles")
## Saving ../tlocohShapefiles/cc.s0.03.a15000.02.hpp.shp
## Saving ../tlocohShapefiles/cc.s0.03.a15000.02.hulls.shp
## Saving ../tlocohShapefiles/cc.s0.03.a15000.iso.srt-nep.iso-q.h899.i5.02.iso.shp
## Saving ../tlocohShapefiles/cc.s0.03.a15000.iso.srt-ecc.iso-q.h899.i5.02.iso.shp
## Total time: 0.3 secs
As far as I’m aware the time data is already in local time so no transformation required
#fox.db$dt <- as.POSIXct(strptime(fox.db$DATETIME, format="%d/%m/%Y %H:%M"))
fox.db$dt <- as.POSIXct(fox.db$DATETIME, format="%d/%m/%Y %H:%M", tz="Australia/Perth")
db <- fox.db[,c("LONGITUDE","LATITUDE","dt","ANIMALID")]
#rename cols
colnames(db)[1:4] <- c("x","y","dt","id")
#check first 4 lines of the dataframe
db[1:4,]
give x and y a projection This creates the first of a series of new dataframes that are joined. Pretty clunky way to do it but this is what is required in this program
#sub-df 1 latlong
db.sp.latlong <- SpatialPoints(db[ , c("x","y")], proj4string=CRS("+proj=longlat +ellps=WGS84"))
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
db.sp.utm <- spTransform(db.sp.latlong, CRS("+proj=utm +south +zone=50 +ellps=WGS84"))
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
db.mat.utm <- coordinates(db.sp.utm)
tail(db.mat.utm)
## x y
## [570,] 392783.4 6470148
## [571,] 392772.7 6470130
## [572,] 392775.2 6470130
## [573,] 392773.9 6470138
## [574,] 392773.9 6470132
## [575,] 392782.6 6470104
#sub-df 2 local time - the data are already in this so just subset to follow naming format
db.local <- as.POSIXct(db$dt, tz="Australia/Perth")
local.tz <- "Australia/Perth"
db.localtime <- as.POSIXct(format(db.local, tz=local.tz), tz=local.tz)
#sub-df 3 id
db.id <- db[,c("id")]
#merge all the df in the correct tlocoh format and order
db.lxy <- xyt.lxy(xy=db.mat.utm, dt=db.localtime, id="db", proj4string=CRS("+proj=utm +south +zone=50 +ellps=WGS84"))#, dup.dt.check=FALSE)
## 13 duplicate xy-time-id rows removed
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
Explore the structure of the lxy object
nrow(db.lxy$pts)
## [1] 562
summary(db.lxy)
## Summary of LoCoH-xy object: db.lxy
## ***Locations
## id num.pts dups
## db 562 3
## ***Time span
## id begin end period
## db 2016-07-08 2016-08-02 25.2 days
## ***Spatial extent
## x: 391447.9 - 392816.5
## y: 6469968 - 6470911.1
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## db 1800 (30min) 27.47589 0.6401673
## ***Ancilliary Variables:
## -none-
## ***Nearest-neighbor set(s):
## none saved
Plot out the movement trajectory
plot(db.lxy)
Display the distribution of locations by date, step length, and sampling interval.
hist(db.lxy)
Review the sampling frequency
lxy.plot.freq(db.lxy, cp=T)
Construct a model of space-use without considering time (s=0). k=25 means that it is considering the nearest 25 points to the parent point (at this stage its completely arbitrary). As we are not considering time these points are the nearest in space and as such may not necessarily be sequential.
db.lxy <- lxy.nn.add(db.lxy, s=0, k=25)
## Finding nearest neighbors for id=db (n=562), num.parent.pts=562,
## mode=Fixed-k, k=25, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: db|vmax|s0|n562|kmax25|rmax9.4|amax136.5
##
## Done. Nearest neighbor set(s) created / updated:
## db|vmax|s0|n562|kmax25|rmax9.4|amax136.5
## Total time: 0 secs
summary(db.lxy)
## Summary of LoCoH-xy object: db.lxy
## ***Locations
## id num.pts dups
## db 562 3
## ***Time span
## id begin end period
## db 2016-07-08 2016-08-02 25.2 days
## ***Spatial extent
## x: 391447.9 - 392816.5
## y: 6469968 - 6470911.1
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## db 1800 (30min) 27.47589 0.6401673
## ***Ancilliary Variables:
## -none-
## ***Nearest-neighbor set(s):
## 1 db|vmax|s0|n562|kmax25|rmax9.4|amax136.5
Save the lxy object for later analysis (when look at the time stuff)
lxy.save(db.lxy, dir="../data")
## LoCoH-xy db.lxy saved as db.lxy to:
## C:\Users\20120252\Dropbox (Personal)\Statistics\Projects\Project - Foxes\data\db.n562.2016-07-08.2016-08-02.lxy.03.RData
Make a kml to visualise the track on GoogleEarth so can get a feel for the animals movement. This is easy but produces a pretty awful result. Doesn’t appear to read the dt appropriately. Gives and enddate in 2021 Check our the t-locoh extension tutorial to see if there is a better way to do this.
lxy.exp.kml(db.lxy, 'db.lxy.191121.kml',compress = FALSE, pt.scale = 0.25, path.lwd = 3)
## Loading required namespace: XML
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
## Reprojecting data to +proj=longlat +datum=WGS84...Done.
## Exporting locations
##
|
| | 0%
|
| | 1%
|
|= | 1%
|
|= | 2%
|
|== | 2%
|
|== | 3%
|
|== | 4%
|
|=== | 4%
|
|=== | 5%
|
|==== | 5%
|
|==== | 6%
|
|===== | 7%
|
|===== | 8%
|
|====== | 8%
|
|====== | 9%
|
|======= | 9%
|
|======= | 10%
|
|======= | 11%
|
|======== | 11%
|
|======== | 12%
|
|========= | 12%
|
|========= | 13%
|
|========= | 14%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 15%
|
|=========== | 16%
|
|============ | 17%
|
|============ | 18%
|
|============= | 18%
|
|============= | 19%
|
|============== | 19%
|
|============== | 20%
|
|============== | 21%
|
|=============== | 21%
|
|=============== | 22%
|
|================ | 22%
|
|================ | 23%
|
|================= | 24%
|
|================= | 25%
|
|================== | 25%
|
|================== | 26%
|
|=================== | 27%
|
|=================== | 28%
|
|==================== | 28%
|
|==================== | 29%
|
|===================== | 29%
|
|===================== | 30%
|
|===================== | 31%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 32%
|
|======================= | 33%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 35%
|
|========================= | 36%
|
|========================== | 36%
|
|========================== | 37%
|
|========================== | 38%
|
|=========================== | 38%
|
|=========================== | 39%
|
|============================ | 39%
|
|============================ | 40%
|
|============================ | 41%
|
|============================= | 41%
|
|============================= | 42%
|
|============================== | 42%
|
|============================== | 43%
|
|=============================== | 44%
|
|=============================== | 45%
|
|================================ | 45%
|
|================================ | 46%
|
|================================= | 46%
|
|================================= | 47%
|
|================================= | 48%
|
|================================== | 48%
|
|================================== | 49%
|
|=================================== | 49%
|
|=================================== | 50%
|
|=================================== | 51%
|
|==================================== | 51%
|
|==================================== | 52%
|
|===================================== | 52%
|
|===================================== | 53%
|
|===================================== | 54%
|
|====================================== | 54%
|
|====================================== | 55%
|
|======================================= | 55%
|
|======================================= | 56%
|
|======================================== | 57%
|
|======================================== | 58%
|
|========================================= | 58%
|
|========================================= | 59%
|
|========================================== | 59%
|
|========================================== | 60%
|
|========================================== | 61%
|
|=========================================== | 61%
|
|=========================================== | 62%
|
|============================================ | 62%
|
|============================================ | 63%
|
|============================================ | 64%
|
|============================================= | 64%
|
|============================================= | 65%
|
|============================================== | 65%
|
|============================================== | 66%
|
|=============================================== | 67%
|
|=============================================== | 68%
|
|================================================ | 68%
|
|================================================ | 69%
|
|================================================= | 69%
|
|================================================= | 70%
|
|================================================= | 71%
|
|================================================== | 71%
|
|================================================== | 72%
|
|=================================================== | 72%
|
|=================================================== | 73%
|
|==================================================== | 74%
|
|==================================================== | 75%
|
|===================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 77%
|
|====================================================== | 78%
|
|======================================================= | 78%
|
|======================================================= | 79%
|
|======================================================== | 79%
|
|======================================================== | 80%
|
|======================================================== | 81%
|
|========================================================= | 81%
|
|========================================================= | 82%
|
|========================================================== | 82%
|
|========================================================== | 83%
|
|=========================================================== | 84%
|
|=========================================================== | 85%
|
|============================================================ | 85%
|
|============================================================ | 86%
|
|============================================================= | 86%
|
|============================================================= | 87%
|
|============================================================= | 88%
|
|============================================================== | 88%
|
|============================================================== | 89%
|
|=============================================================== | 89%
|
|=============================================================== | 90%
|
|=============================================================== | 91%
|
|================================================================ | 91%
|
|================================================================ | 92%
|
|================================================================= | 92%
|
|================================================================= | 93%
|
|================================================================== | 94%
|
|================================================================== | 95%
|
|=================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 96%
|
|==================================================================== | 97%
|
|==================================================================== | 98%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 99%
|
|======================================================================| 100%
## db.lxy.191121.kml created
The building blocks of all T-LoCoH analyses are hulls, which are simply minimum convex polygons constructed around each point from a set of nearest neighbors. Since we’ve already identified 25 nearest neighbors for each point, we can create hulls with up to 25 nearest neighbors each. We will use the tlocoh::lxy.lhs command to create an lhs object, the next in our progression.
db.lhs <- lxy.lhs(db.lxy, k=3*3:8, s=0)
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## db: 3 duplicate points were randomly displaced by 1 map unit(s)
##
## db.pts562.k9.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## db.pts562.k12.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## db.pts562.k15.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## db.pts562.k18.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## db.pts562.k21.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## db.pts562.k24.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## The following hullsets were generated:
## db.pts562.k9.s0.kmin0
## db.pts562.k12.s0.kmin0
## db.pts562.k15.s0.kmin0
## db.pts562.k18.s0.kmin0
## db.pts562.k21.s0.kmin0
## db.pts562.k24.s0.kmin0
## Total time: 0.7 secs
What we are doing here is creating 6 different hullsets with k values of 9, 12, 15, 18, 21, and 24 (note we are still setting s=0 because we are not considering the temporal component yet). It is useful to create a selection of hullsets so that we can compare them and choose the optimal one for our purposes. The downside of creating all of these extra hullsets is that it may take a little while to run. Once it is finished, we can get an idea of what areas are included in our hullsets using the tlocoh::plot command again. This time, we will specify that we want to plot the hulls and we’ll add all of the plots to a single page for easier comparison.
plot(db.lhs, hulls=TRUE, figs.per.page=6)
Isopleths are aggregations of hulls sorted in such a way as to reveal something about space use. The default settings for tlocoh::lhs.iso.add sorts hulls according to density, so the isopleths reflect the likelihood of occurrence, which is a proxy for intensity of use. Then we can plot these (using the iso=TRUE specification instead of hulls=TRUE) to see how they compare to one another and to the hullset plots.
db.lhs <- lhs.iso.add(db.lhs)
## Merging hulls into isopleths
## db.pts562.k9.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## 1 invalid polygon(s) removed
## db.pts562.k12.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## db.pts562.k15.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## db.pts562.k18.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## db.pts562.k21.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## db.pts562.k24.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Total time: 0.3 secs
plot(db.lhs, iso=TRUE, figs.per.page=6)
plot(db.lhs, iso=T, k=15, allpts=T, cex.allpts=0.1, col.allpts="gray10", ufipt=F)
Note: you can also produce the above plot without the pts. In this case just use: plot(cc.lhs, iso=T, k=15, ufipt=F). I originally ran this with k=18 which looked ok mapping this iso’s but when I ran the plots below it looks like k=15 might be better.
Two other plots can be used to evaluate the choice of k value. The first is the isopleth area curves, which will plot the area included in a set of different isopleth levels (ranging from 0.15 to 0.95 by 0.10). We want to check these plots to make sure that there are no sharp jumps between k values that indicate that a relatively small change in k results in a large increase in included area (likely a false commission). To look at this plot, we use the tlocoh::lhs.plot.isoarea command:
lhs.plot.isoarea(db.lhs)
There’s a bit of a jump after 15….
Next - look at the edge to area ratio. We are looking to exclude k values that result in very high edge:area ratios, which are indicative of the Swiss cheese pattern (i.e., many small holes). This is particularly important at some of the isopleths associated with the core area (0.35, 0.45, 0.55) where we would expect relatively few holes.
lhs.plot.isoear(db.lhs)
If the plots are too small in the RMarkdown window then put the code into the Console and view the plot in the plot window. Resize this area first so that the plot is nice and big. Having run all the k values multiple time k=15 is actually the best. i.e. using a larger value of k doesnt really change how many of the grey dtps are included in the hulls.
Select this value for subsequent runs and save as an object
db.lhs.k15 <- lhs.select(db.lhs, k=15)
lhs.save(db.lhs.k15, dir="../data")
## LoCoH-hullset db.lhs.k15 saved as 'db.lhs.k15' to:
## C:\Users\20120252\Dropbox (Personal)\Statistics\Projects\Project - Foxes\data\db.n562.s0.k15.iso.lhs.03.RData
If doing this step in another session then you need to load the lxy and lhs RData files that you saved above. Use the following syntax:
load(‘./data/db.n562.2016-07-08.2016-08-02.lxy.01.RData’) load(‘./data/db.n562.s0.k15.iso.lhs.01.RData’)
create a new nearest neighbor set with a non-zero s parameter. That is, we are now creating a UD that incorporates time. In the first plot there are points in the same general areas that are colour coded differently. This means that they were in the same area but at different times so these points are not temporally related. In the s=0 calculations above this is ignored and therefore is not ecologically very informative.
Firstly, need to select a ‘decent’ s value. To do this pick an s value such that 40-80% of the hulls are ‘time-selected.’
This is Method 1
db.lxy <- lxy.ptsh.add(db.lxy)
## id: db
## Randomly selected 200 of 562 points
## Finding 10 nearest neighbors for 200 sample points
## Finding s for ptsh=0.98
## s=0.005, s=0.01, s=0.02, s=0.04, s=0.08, s=0.16, s=0.32,
## Finding s for ptsh=0.1 (+/- 0.01)
## s=0.0025, s=0.00125, s=0.001875, s=0.0015625,
## Finding s for ptsh=0.2 (+/- 0.01)
## s=0.00375, s=0.003125, s=0.0028125, s=0.00265625, s=0.002734375,
## Finding s for ptsh=0.3 (+/- 0.01)
## s=0.004375,
## Finding s for ptsh=0.4 (+/- 0.01)
## s=0.0075, s=0.00625, s=0.006875, s=0.0065625,
## Finding s for ptsh=0.5 (+/- 0.01)
## Finding s for ptsh=0.6 (+/- 0.01)
## Finding s for ptsh=0.7 (+/- 0.01)
## s=0.06, s=0.05,
## Finding s for ptsh=0.8 (+/- 0.01)
## Finding s for ptsh=0.9 (+/- 0.01)
## s=0.12,
##
## Done with db
This creates a set of 200 sample points, each with 10 nearest neighbors. This algorithm goes through a set of different s values and determines what proportion of hulls are time-selected (ptsh). Though this is a somewhat stochastic process, we can see that s values between approximately 0.01 and 0.08 fall between proportions of time-selected hulls ranging from about 40-80%. Its more easily understood just by looking at the plot.
Method 2 Select a time interval that is ecologically relevant. We are interested in daily movement (e.g. night time foraging), so a 24hr cycle is OK - on the premise that points that are close together but more than 24hrs apart are not related. If you are thinking about longer temporal patterns (e.g. season), then you need to adjust the value accordingly. If you dont have a clue and are fishing for patterns then do this:
lxy.plot.pt2ctr(db.lxy)
and then do this:
lxy.plot.sfinder(db.lxy)
then do this:
#note: 3600 = 1 hour (3600 seconds)
lxy.plot.sfinder(db.lxy, delta.t=3600*c(12,24,36,48,54,60))
Both methods support an s=0.03 value at the scale of 24hrs. According to the manual these methods don’t necessarily always converge. Apparently that is not an issue as the methods are extremely different.
using s= 0.6 (not really sure about this. Basing it on the first graph L 976, and retaining k = 25 (value used in the distance only method)
db.lxy <- lxy.nn.add(db.lxy, s=0.06, k=25)
## Finding nearest neighbors for id=db (n=562), num.parent.pts=562,
## mode=Fixed-k, k=25, s=0.06, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: db|vmax|s0.06|n562|kmax25|rmax898.8|amax11700.6
##
## Done. Nearest neighbor set(s) created / updated:
## db|vmax|s0.06|n562|kmax25|rmax898.8|amax11700.6
## Total time: 0.5 secs
this adds another NN set to db.lxy ie it includes it as another list. To view:
summary(db.lxy)
## Summary of LoCoH-xy object: db.lxy
## ***Locations
## id num.pts dups
## db 562 3
## ***Time span
## id begin end period
## db 2016-07-08 2016-08-02 25.2 days
## ***Spatial extent
## x: 391447.9 - 392816.5
## y: 6469968 - 6470911.1
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## db 1800 (30min) 27.47589 0.6401673
## ***Ancilliary Variables:
## -none-
## ***ptsh s-values computed
## id k n ptsh
## db 10 200 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98
## ***Nearest-neighbor set(s):
## 1 db|vmax|s0|n562|kmax25|rmax9.4|amax136.5
## 2 db|vmax|s0.06|n562|kmax25|rmax898.8|amax11700.6
Note the huge difference in the rmax and amax values (perhaps better to use these methods than fixed k)
Can also calculate s in the same way that calculated k. This next section follows the method to do this. I don’t think its necessary as we have already used a decent method above but I will run through this method just to see if the choice is the same.
db.lxy <- lxy.nn.add(db.lxy, s=c(0.0006, 0.006, 0.06, 0.6), k=25)
## Finding nearest neighbors for id=db (n=562), num.parent.pts=562,
## mode=Fixed-k, k=25, s=6e-04, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: db|vmax|s6e-04|n562|kmax25|rmax19.7|amax326.9
## Finding nearest neighbors for id=db (n=562), num.parent.pts=562,
## mode=Fixed-k, k=25, s=0.006, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: db|vmax|s0.006|n562|kmax25|rmax90|amax1291.6
## Finding nearest neighbors for id=db (n=562), num.parent.pts=562,
## mode=Fixed-k, k=25, s=0.06, method=TSD:vmax
## - there is already a set of nearest neighbors for this set of parent
## points and value of s.
## - enough points already saved, no need to find more
## Finding nearest neighbors for id=db (n=562), num.parent.pts=562,
## mode=Fixed-k, k=25, s=0.6, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: db|vmax|s0.6|n562|kmax25|rmax8987.9|amax116845
##
## Done. Nearest neighbor set(s) created / updated:
## db|vmax|s6e-04|n562|kmax25|rmax19.7|amax326.9
## db|vmax|s0.006|n562|kmax25|rmax90|amax1291.6
## db|vmax|s0.6|n562|kmax25|rmax8987.9|amax116845
## Total time: 1.4 secs
lxy.plot.mtdr(db.lxy, k=10)
## Computing maximum theoretical distance over TSD for db
##
|
| | 0%
|
|============== | 20%
|
|============================ | 40%
|
|========================================== | 60%
|
|======================================================== | 80%
|
|======================================================================| 100%
lxy.plot.tspan(db.lxy, k=10)
## Computing time span for db
##
|
| | 0%
|
|============== | 20%
|
|============================ | 40%
|
|========================================== | 60%
|
|======================================================== | 80%
|
|======================================================================| 100%
Comment from the tutorial “These methods still leave a great deal up to the researcher, which has its pros and cons, but at least you’ve got quite a few alternatives for selecting an ideal s value for your particular purposes”. We’ll stick with our 0.06 value for now, but we’ll need to create a new lhs object using this parameter:
db.lhs.time <- lxy.lhs(db.lxy, k=3*3:8, s=0.06)
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## db: 3 duplicate points were randomly displaced by 1 map unit(s)
##
## db.pts562.k9.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## db.pts562.k12.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## db.pts562.k15.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## db.pts562.k18.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## db.pts562.k21.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## db.pts562.k24.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## The following hullsets were generated:
## db.pts562.k9.s0.06.kmin0
## db.pts562.k12.s0.06.kmin0
## db.pts562.k15.s0.06.kmin0
## db.pts562.k18.s0.06.kmin0
## db.pts562.k21.s0.06.kmin0
## db.pts562.k24.s0.06.kmin0
## Total time: 1.1 secs
Merge the hulls into isopleths
db.lhs.time <- lhs.iso.add(db.lhs.time)
## Merging hulls into isopleths
## db.pts562.k9.s0.06.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## db.pts562.k12.s0.06.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## db.pts562.k15.s0.06.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## db.pts562.k18.s0.06.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## db.pts562.k21.s0.06.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## db.pts562.k24.s0.06.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Total time: 0.2 secs
Plot the isopleths
plot(db.lhs.time, iso=TRUE, figs.per.page=6)
When I was going through these in R I changed the figs.per.page to =1 as its too hard to see things on the screen. I’m not entirely sure that k=15 is the best but it is better than the other k’s. I think maybe it might be a good idea to play with the other parameters r and a.
Compare with time version to the original distance only method
db.lhs.time.k15 <- lhs.select(db.lhs.time, k=15) #distance only
plot(db.lhs.k15, iso=TRUE, figs.per.page=1)
plot(db.lhs.time.k15, iso=TRUE, figs.per.page=1) #with time
Save the time selected hullset to use with additional work if taking a break at this point.
#lhs.save(db.lhs.time.k15, dir="../data")
db.isos <- isopleths(db.lhs.k15)
db.isos[[1]]@data
db.time.isos <- isopleths(db.lhs.time.k15)
db.time.isos[[1]]@data
db.core <- db.isos[[1]][ db.isos[[1]][["iso.level"]]==0.5, ]
db.hr <- db.isos[[1]][ db.isos[[1]][["iso.level"]]==0.95, ]
plot(db.hr, border="blue")
plot(db.core, border="red", add=T)
db.time.isos <- isopleths(db.lhs.time.k15) db.time.isos[[1]]@data
Plot calculation of area|time vis
db.time.core <- db.time.isos[[1]][ db.time.isos[[1]][["iso.level"]]==0.5, ]
db.time.hr <- db.time.isos[[1]][ db.time.isos[[1]][["iso.level"]]==0.95, ]
plot(db.time.hr, border="blue")
plot(db.time.core, border="red", add=T)
see p20 in the tlocoh_tutorial.pdf (in the help file)
Reasoning for using it: The ‘a’ in a-method stands for adaptive, because this method is designed to reduce the number of neighbors used in areas where the points are thin and scattered. Neighbors are identified by summing up their cumulative distance from the parent point and stopping when you reach a. This may result in a many points being labeled as neighbors in a dense area (which is what you probably want), and just a few points in outlying areas (which is also what you want).
The workflow is the same as the k method, BUT deciding on a value of ‘a’ is not straightforward because: 1) a is a cumulative distance from the parent point to the nearest neighbors 2) if time is included, the ‘distance’ between points is the TSD space-time metric which is not a physical distance.
To assist in picking an appropriate value of ‘a’ the auto.a function is used. This computes the ‘a’ value such that p% of points get at least n nearest neighbours, where p and n are supplied by you.
So for example, if we like the results with k=15, we can use auto.a() to tell us the value of ‘a’ that will result in 98% of all points having 15 or more nearest neighbours.
db.a.lxy <- lxy.nn.add(db.lxy, s=0.06, a=auto.a(nnn=15, ptp=0.98))
## Finding nearest neighbors for id=db (n=562), num.parent.pts=562,
## mode=Auto-a, auto.a=nn|0.98|15|1.05, s=0.06, method=TSD:vmax
## - there is already a set of nearest neighbors for this set of parent
## points and value of s.
## - additional neighbors will be identified and appended as needed
## - computing auto-a...
## - found from existing NN set. Auto-a is 21099.49
## - finding an initial value of k using 30 randomly selected points...Done.
## - Initial k=28
## - computing cumulative distances for k=28
## - 28 wasn't large enough for 139 points. Computing cumulative
## distances for k=56 points
## - 4744 additional neighbors appended
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: db|vmax|s0.06|n562|kmax25|rmax1101.4|amax21151.7
##
## Done. Nearest neighbor set(s) created / updated:
## db|vmax|s0.06|n562|kmax25|rmax1101.4|amax21151.7
## Total time: 0.5 secs
summary(db.a.lxy)
## Summary of LoCoH-xy object: db.a.lxy
## ***Locations
## id num.pts dups
## db 562 3
## ***Time span
## id begin end period
## db 2016-07-08 2016-08-02 25.2 days
## ***Spatial extent
## x: 391447.9 - 392816.5
## y: 6469968 - 6470911.1
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## db 1800 (30min) 27.47589 0.6401673
## ***Ancilliary Variables:
## -none-
## ***ptsh s-values computed
## id k n ptsh
## db 10 200 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98
## ***Nearest-neighbor set(s):
## 1 db|vmax|s0|n562|kmax25|rmax9.4|amax136.5
## 2 db|vmax|s6e-04|n562|kmax25|rmax19.7|amax326.9
## 3 db|vmax|s0.006|n562|kmax25|rmax90|amax1291.6
## 5 db|vmax|s0.06|n562|kmax25|rmax1101.4|amax21151.7
## meth ptp nnn tct aVal
## auto.a #1 nn 0.98 15 1.05 21099.49
## 4 db|vmax|s0.6|n562|kmax25|rmax8987.9|amax116845
This summary output tells us that for s= 0.06, if a = 21129.9, that 98% of pts will have at least 15 nn.
You can now use this to set the range of a values to test to calculate the hullsets. For example: could test a = 12000, 13000, ……23000, then view the isopleth plots to see if happy or whether still need to fine tune things. This is really subjective, but this is actually how its done!
db.a.lxy <- lxy.nn.add(db.a.lxy, s=0.06, a=23000)
## Finding nearest neighbors for id=db (n=562), num.parent.pts=562,
## mode=Fixed-a, a=23000, s=0.06, method=TSD:vmax
## - there is already a set of nearest neighbors for this set of parent
## points and value of s.
## - additional neighbors will be identified and appended as needed
## - finding an initial value of k using 30 randomly selected points...Done.
## - Initial k=30
## - computing cumulative distances for k=30
## - 355 additional neighbors appended
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: db|vmax|s0.06|n562|kmax25|rmax1176.3|amax23008.3
##
## Done. Nearest neighbor set(s) created / updated:
## db|vmax|s0.06|n562|kmax25|rmax1176.3|amax23008.3
## Total time: 0.2 secs
summary(cc.a.lxy)
## Summary of LoCoH-xy object: cc.a.lxy
## ***Locations
## id num.pts dups
## cc 900 3
## ***Time span
## id begin end period
## cc 2016-06-04 2016-08-02 58.8 days
## ***Spatial extent
## x: 391251.3 - 394058.5
## y: 6469647.1 - 6472684.7
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## cc 1800 (30min) 114.9905 1.230966
## ***Ancilliary Variables:
## -none-
## ***ptsh s-values computed
## id k n ptsh
## cc 10 200 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98
## ***Nearest-neighbor set(s):
## 1 cc|vmax|s0|n900|kmax25|rmax7.8|amax113.1
## 2 cc|vmax|s3e-04|n900|kmax25|rmax34|amax588.6
## 3 cc|vmax|s0.003|n900|kmax25|rmax173.5|amax2669.2
## 5 cc|vmax|s0.03|n900|kmax25|rmax1109.4|amax21014.6
## meth ptp nnn tct aVal
## auto.a #1 nn 0.98 15 1.05 18281.8
## 4 cc|vmax|s0.3|n900|kmax25|rmax8642.8|amax112506.8
At this point also add the isopleths; previously we did this as a seperate step
db.lhs.amixed <- lxy.lhs(db.a.lxy, s=0.06, a=8:25*1000, iso.add=T)
## Using nearest-neighbor selection mode: Fixed-a
## Constructing hulls and hull metrics...
## db: 3 duplicate points were randomly displaced by 1 map unit(s)
##
## db.pts562.a8000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a9000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a10000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a11000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a12000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a13000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a14000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a15000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a16000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a17000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a18000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a19000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a20000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a21000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a22000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a23000.s0.06.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## db.pts562.a24000.s0.06.kmin0
## - Unfortunately there isn't a set of nearest neighbors in lxy for this
## value of s :-( Run lxy.nn.add() and try again
##
## db.pts562.a25000.s0.06.kmin0
## - Unfortunately there isn't a set of nearest neighbors in lxy for this
## value of s :-( Run lxy.nn.add() and try again
## The following hullsets were generated:
## db.pts562.a8000.s0.06.kmin0
## db.pts562.a9000.s0.06.kmin0
## db.pts562.a10000.s0.06.kmin0
## db.pts562.a11000.s0.06.kmin0
## db.pts562.a12000.s0.06.kmin0
## db.pts562.a13000.s0.06.kmin0
## db.pts562.a14000.s0.06.kmin0
## db.pts562.a15000.s0.06.kmin0
## db.pts562.a16000.s0.06.kmin0
## db.pts562.a17000.s0.06.kmin0
## db.pts562.a18000.s0.06.kmin0
## db.pts562.a19000.s0.06.kmin0
## db.pts562.a20000.s0.06.kmin0
## db.pts562.a21000.s0.06.kmin0
## db.pts562.a22000.s0.06.kmin0
## db.pts562.a23000.s0.06.kmin0
## The following hullsets were NOT generated because no suitable
## nearest-neighbor set was found:
## db.pts562.a24000.s0.06.kmin0
## db.pts562.a25000.s0.06.kmin0
## Total time: 3.3 secs
plot(db.lhs.amixed, hulls=TRUE,figs.per.page=6)
plot(db.lhs.amixed, iso=TRUE, figs.per.page=6)
to try an help with interpreting the which value of a is reasonable
lhs.plot.isoarea(db.lhs.amixed)
lhs.plot.isoear(db.lhs.amixed)
This suggests that a= 19000 should be used instead of a = 21000
plot(db.lhs.amixed, hulls=T, a=19000, allpts=T, cex.allpts=0.1, col.allpts="gray10", ufipt=F)
plot(db.lhs.amixed, iso=T, a=19000, allpts=T, cex.allpts=0.1, col.allpts="gray10", ufipt=F)
# calculation of area|time|a method
db.timea.isos <- isopleths(db.lhs.amixed, a=19000)
db.timea.isos[[1]]@data
The previous time fixed k method gave 50% as 7.5ha, 95% as 50.4ha Here we have 49ha and 60ha
Fill these data results into hr2.area1.xlsx in the atm project
#Calculation of area|time|a method with pts overlay
db.timea.core <- db.timea.isos[[1]][ db.timea.isos[[1]][["iso.level"]]==0.5, ]
db.timea.hr <- db.timea.isos[[1]][ db.timea.isos[[1]][["iso.level"]]==0.95, ]
plot(db.timea.hr, border="blue")
plot(db.timea.core, border="red", add=T)
plot(db.lhs.amixed,a=19000, allpts=T, cex.allpts=0.1, col.allpts="gray10", ufipt=F, add=T)
As far as I’m aware the time data is already in local time so no transformation required
#fox.db$dt <- as.POSIXct(strptime(fox.db$DATETIME, format="%d/%m/%Y %H:%M"))
fox.es$dt <- as.POSIXct(fox.es$DATETIME, format="%d/%m/%Y %H:%M", tz="Australia/Perth")
es <- fox.es[,c("LONGITUDE","LATITUDE","dt","ANIMALID")]
#rename cols
colnames(es)[1:4] <- c("x","y","dt","id")
#check first 4 lines of the dataframe
es[1:4,]
give x and y a projection This creates the first of a series of new dataframes that are joined. Pretty clunky way to do it but this is what is required in this program
#sub-df 1 latlong
es.sp.latlong <- SpatialPoints(es[ , c("x","y")], proj4string=CRS("+proj=longlat +ellps=WGS84"))
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
es.sp.utm <- spTransform(es.sp.latlong, CRS("+proj=utm +south +zone=50 +ellps=WGS84"))
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
es.mat.utm <- coordinates(es.sp.utm)
tail(es.mat.utm)
## x y
## [1868,] 385894.3 6474302
## [1869,] 385899.0 6474303
## [1870,] 385895.4 6474301
## [1871,] 385889.4 6474306
## [1872,] 385903.8 6474304
## [1873,] 385887.0 6474303
#sub-df 2 local time - the data are already in this so just subset to follow naming format
es.local <- as.POSIXct(es$dt, tz="Australia/Perth")
local.tz <- "Australia/Perth"
es.localtime <- as.POSIXct(format(es.local, tz=local.tz), tz=local.tz)
#sub-df 3 id
es.id <- es[,c("id")]
#merge all the df in the correct tlocoh format and order
es.lxy <- xyt.lxy(xy=es.mat.utm, dt=es.localtime, id="es", proj4string=CRS("+proj=utm +south +zone=50 +ellps=WGS84"))#, dup.dt.check=FALSE)
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
Explore the structure of the lxy object
nrow(es.lxy$pts)
## [1] 1873
summary(es.lxy)
## Summary of LoCoH-xy object: es.lxy
## ***Locations
## id num.pts dups
## es 1873 223
## ***Time span
## id begin end period
## es 2016-01-15 2016-03-15 59.9 days
## ***Spatial extent
## x: 385162.4 - 386607.6
## y: 6472199.2 - 6475289.3
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## es 1800 (30min) 14.07779 0.4336227
## ***Ancilliary Variables:
## -none-
## ***Nearest-neighbor set(s):
## none saved
Plot out the movement trajectory
plot(es.lxy)
Display the distribution of locations by date, step length, and sampling interval.
hist(es.lxy)
Review the sampling frequency
lxy.plot.freq(es.lxy, cp=T)
Construct a model of space-use without considering time (s=0). k=25 means that it is considering the nearest 25 points to the parent point (at this stage its completely arbitrary). As we are not considering time these points are the nearest in space and as such may not necessarily be sequential.
es.lxy <- lxy.nn.add(es.lxy, s=0, k=25)
## Finding nearest neighbors for id=es (n=1873), num.parent.pts=1873,
## mode=Fixed-k, k=25, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: es|vmax|s0|n1873|kmax25|rmax1.2|amax19.3
##
## Done. Nearest neighbor set(s) created / updated:
## es|vmax|s0|n1873|kmax25|rmax1.2|amax19.3
## Total time: 0 secs
summary(es.lxy)
## Summary of LoCoH-xy object: es.lxy
## ***Locations
## id num.pts dups
## es 1873 223
## ***Time span
## id begin end period
## es 2016-01-15 2016-03-15 59.9 days
## ***Spatial extent
## x: 385162.4 - 386607.6
## y: 6472199.2 - 6475289.3
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## es 1800 (30min) 14.07779 0.4336227
## ***Ancilliary Variables:
## -none-
## ***Nearest-neighbor set(s):
## 1 es|vmax|s0|n1873|kmax25|rmax1.2|amax19.3
Save the lxy object for later analysis (when look at the time stuff)
lxy.save(es.lxy, dir="../data")
## LoCoH-xy es.lxy saved as es.lxy to:
## C:\Users\20120252\Dropbox (Personal)\Statistics\Projects\Project - Foxes\data\es.n1873.2016-01-15.2016-03-15.lxy.05.RData
Make a kml to visualise the track on GoogleEarth so can get a feel for the animals movement. This is easy but produces a pretty awful result. Doesn’t appear to read the dt appropriately. Gives and enddate in 2021 Check our the t-locoh extension tutorial to see if there is a better way to do this. For some reason I cant get this to save in a folder so it will go into the script folder by default.
lxy.exp.kml(es.lxy, 'es.lxy.221121.kml',compress = FALSE, pt.scale = 0.25, path.lwd = 3)
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
## Reprojecting data to +proj=longlat +datum=WGS84...Done.
## Exporting locations
##
|
| | 0%
|
| | 1%
|
|= | 1%
|
|= | 2%
|
|== | 2%
|
|== | 3%
|
|== | 4%
|
|=== | 4%
|
|=== | 5%
|
|==== | 5%
|
|==== | 6%
|
|===== | 6%
|
|===== | 7%
|
|===== | 8%
|
|====== | 8%
|
|====== | 9%
|
|======= | 9%
|
|======= | 10%
|
|======= | 11%
|
|======== | 11%
|
|======== | 12%
|
|========= | 12%
|
|========= | 13%
|
|========= | 14%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 15%
|
|=========== | 16%
|
|============ | 16%
|
|============ | 17%
|
|============ | 18%
|
|============= | 18%
|
|============= | 19%
|
|============== | 19%
|
|============== | 20%
|
|============== | 21%
|
|=============== | 21%
|
|=============== | 22%
|
|================ | 22%
|
|================ | 23%
|
|================ | 24%
|
|================= | 24%
|
|================= | 25%
|
|================== | 25%
|
|================== | 26%
|
|=================== | 26%
|
|=================== | 27%
|
|=================== | 28%
|
|==================== | 28%
|
|==================== | 29%
|
|===================== | 29%
|
|===================== | 30%
|
|===================== | 31%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 32%
|
|======================= | 33%
|
|======================= | 34%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 35%
|
|========================= | 36%
|
|========================== | 36%
|
|========================== | 37%
|
|========================== | 38%
|
|=========================== | 38%
|
|=========================== | 39%
|
|============================ | 39%
|
|============================ | 40%
|
|============================ | 41%
|
|============================= | 41%
|
|============================= | 42%
|
|============================== | 42%
|
|============================== | 43%
|
|============================== | 44%
|
|=============================== | 44%
|
|=============================== | 45%
|
|================================ | 45%
|
|================================ | 46%
|
|================================= | 46%
|
|================================= | 47%
|
|================================= | 48%
|
|================================== | 48%
|
|================================== | 49%
|
|=================================== | 49%
|
|=================================== | 50%
|
|=================================== | 51%
|
|==================================== | 51%
|
|==================================== | 52%
|
|===================================== | 52%
|
|===================================== | 53%
|
|===================================== | 54%
|
|====================================== | 54%
|
|====================================== | 55%
|
|======================================= | 55%
|
|======================================= | 56%
|
|======================================== | 56%
|
|======================================== | 57%
|
|======================================== | 58%
|
|========================================= | 58%
|
|========================================= | 59%
|
|========================================== | 59%
|
|========================================== | 60%
|
|========================================== | 61%
|
|=========================================== | 61%
|
|=========================================== | 62%
|
|============================================ | 62%
|
|============================================ | 63%
|
|============================================ | 64%
|
|============================================= | 64%
|
|============================================= | 65%
|
|============================================== | 65%
|
|============================================== | 66%
|
|=============================================== | 66%
|
|=============================================== | 67%
|
|=============================================== | 68%
|
|================================================ | 68%
|
|================================================ | 69%
|
|================================================= | 69%
|
|================================================= | 70%
|
|================================================= | 71%
|
|================================================== | 71%
|
|================================================== | 72%
|
|=================================================== | 72%
|
|=================================================== | 73%
|
|=================================================== | 74%
|
|==================================================== | 74%
|
|==================================================== | 75%
|
|===================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 76%
|
|====================================================== | 77%
|
|====================================================== | 78%
|
|======================================================= | 78%
|
|======================================================= | 79%
|
|======================================================== | 79%
|
|======================================================== | 80%
|
|======================================================== | 81%
|
|========================================================= | 81%
|
|========================================================= | 82%
|
|========================================================== | 82%
|
|========================================================== | 83%
|
|========================================================== | 84%
|
|=========================================================== | 84%
|
|=========================================================== | 85%
|
|============================================================ | 85%
|
|============================================================ | 86%
|
|============================================================= | 86%
|
|============================================================= | 87%
|
|============================================================= | 88%
|
|============================================================== | 88%
|
|============================================================== | 89%
|
|=============================================================== | 89%
|
|=============================================================== | 90%
|
|=============================================================== | 91%
|
|================================================================ | 91%
|
|================================================================ | 92%
|
|================================================================= | 92%
|
|================================================================= | 93%
|
|================================================================= | 94%
|
|================================================================== | 94%
|
|================================================================== | 95%
|
|=================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 96%
|
|==================================================================== | 97%
|
|==================================================================== | 98%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 99%
|
|======================================================================| 100%
## es.lxy.221121.kml created
The building blocks of all T-LoCoH analyses are hulls, which are simply minimum convex polygons constructed around each point from a set of nearest neighbors. Since we’ve already identified 25 nearest neighbors for each point, we can create hulls with up to 25 nearest neighbors each. We will use the tlocoh::lxy.lhs command to create an lhs object, the next in our progression.
es.lhs <- lxy.lhs(es.lxy, k=3*3:8, s=0)
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## es: 223 duplicate points were randomly displaced by 1 map unit(s)
##
## es.pts1873.k9.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## es.pts1873.k12.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## es.pts1873.k15.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## es.pts1873.k18.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## es.pts1873.k21.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## es.pts1873.k24.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## The following hullsets were generated:
## es.pts1873.k9.s0.kmin0
## es.pts1873.k12.s0.kmin0
## es.pts1873.k15.s0.kmin0
## es.pts1873.k18.s0.kmin0
## es.pts1873.k21.s0.kmin0
## es.pts1873.k24.s0.kmin0
## Total time: 2.2 secs
What we are doing here is creating 6 different hullsets with k values of 9, 12, 15, 18, 21, and 24 (note we are still setting s=0 because we are not considering the temporal component yet). It is useful to create a selection of hullsets so that we can compare them and choose the optimal one for our purposes. The downside of creating all of these extra hullsets is that it may take a little while to run. Once it is finished, we can get an idea of what areas are included in our hullsets using the tlocoh::plot command again. This time, we will specify that we want to plot the hulls and we’ll add all of the plots to a single page|or loads of pages(!) for easier comparison.
plot(es.lhs, hulls=TRUE, figs.per.page=1) #if want multiple plots/page then increase No. ie. page = 6
Isopleths are aggregations of hulls sorted in such a way as to reveal something about space use. The default settings for tlocoh::lhs.iso.add sorts hulls according to density, so the isopleths reflect the likelihood of occurrence, which is a proxy for intensity of use. Then we can plot these (using the iso=TRUE specification instead of hulls=TRUE) to see how they compare to one another and to the hullset plots.
es.lhs <- lhs.iso.add(es.lhs)
## Merging hulls into isopleths
## es.pts1873.k9.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 385883.39445719001 6474302.2521317396
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 385896.16078164999 6474301.8295730203
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 385852.36569439998 6474305.7309631798
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 385885.64600174001 6474321.0132899797
## grps.cum.union.lst[[i - 1]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## 2 invalid polygon(s) removed
## es.pts1873.k12.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 385884.39458038 6474328.34082672
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## es.pts1873.k15.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## 1 invalid polygon(s) removed
## es.pts1873.k18.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## es.pts1873.k21.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## es.pts1873.k24.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Total time: 0.9 secs
plot(es.lhs, iso=TRUE, figs.per.page=1)
plot(es.lhs, iso=T, k=21, allpts=T, cex.allpts=0.1, col.allpts="gray80", ufipt=F)
Note: you can also produce the above plot without the pts. In this case just use: plot(es.lhs, iso=T, k=24, ufipt=F). ######ignore - I originally ran this with k=18 which looked ok mapping this iso’s but when I ran ######ignore - the plots below it looks like k=15 might be better.
Two other plots can be used to evaluate the choice of k value. The first is the isopleth area curves, which will plot the area included in a set of different isopleth levels (ranging from 0.15 to 0.95 by 0.10). We want to check these plots to make sure that there are no sharp jumps between k values that indicate that a relatively small change in k results in a large increase in included area (likely a false commission). To look at this plot, we use the tlocoh::lhs.plot.isoarea command:
lhs.plot.isoarea(es.lhs)
There’s a bit of a jump after 15….
Next - look at the edge to area ratio. We are looking to exclude k values that result in very high edge:area ratios, which are indicative of the Swiss cheese pattern (i.e., many small holes). This is particularly important at some of the isopleths associated with the core area (0.35, 0.45, 0.55) where we would expect relatively few holes.
lhs.plot.isoear(es.lhs)
If the plots are too small in the RMarkdown window then put the code into the Console and view the plot in the plot window. Resize this area first so that the plot is nice and big. Having run all the k values multiple times k=18 is actually the best. i.e. using a larger value of k doesnt really change how many of the grey dtps are included in the hulls.
Select this value for subsequent runs and save as an object
es.lhs.k18 <- lhs.select(es.lhs, k=18)
lhs.save(es.lhs.k18, dir="../data")
## LoCoH-hullset es.lhs.k18 saved as 'es.lhs.k18' to:
## C:\Users\20120252\Dropbox (Personal)\Statistics\Projects\Project - Foxes\data\es.n1873.s0.k18.iso.lhs.04.RData
If doing this step in another session then you need to load the lxy and lhs RData files that you saved above. Use the following syntax:
load(‘./data/es.n1873.2016-01-15.2016-03-15.lxy.03.RData’) # es.lxy load(‘./data/es.n1873.s0.k18.iso.lhs.02.RData’) # es.lhs.k18
create a new nearest neighbor set with a non-zero s parameter. That is, we are now creating a UD that incorporates time. In the first plot there are points in the same general areas that are colour coded differently. This means that they were in the same area but at different times so these points are not temporally related. In the s=0 calculations above this is ignored and therefore is not ecologically very informative.
Firstly, need to select a ‘decent’ s value. To do this pick an s value such that 40-80% of the hulls are ‘time-selected.’
This is Method 1
es.lxy <- lxy.ptsh.add(es.lxy)
## id: es
## Randomly selected 200 of 1873 points
## Finding 10 nearest neighbors for 200 sample points
## Finding s for ptsh=0.98
## s=0.005, s=0.01, s=0.02, s=0.04, s=0.08,
## Finding s for ptsh=0.1 (+/- 0.01)
## s=0.0025, s=0.00375, s=0.003125, s=0.0028125,
## Finding s for ptsh=0.2 (+/- 0.01)
## Finding s for ptsh=0.3 (+/- 0.01)
## Finding s for ptsh=0.4 (+/- 0.01)
## s=0.0075, s=0.00625, s=0.005625,
## Finding s for ptsh=0.5 (+/- 0.01)
## s=0.006875,
## Finding s for ptsh=0.6 (+/- 0.01)
## s=0.00875, s=0.008125, s=0.0084375,
## Finding s for ptsh=0.7 (+/- 0.01)
## s=0.015, s=0.0125, s=0.01125,
## Finding s for ptsh=0.8 (+/- 0.01)
## s=0.01375,
## Finding s for ptsh=0.9 (+/- 0.01)
##
## Done with es
This creates a set of 200 sample points, each with 10 nearest neighbors. This algorithm goes through a set of different s values and determines what proportion of hulls are time-selected (ptsh). Though this is a somewhat stochastic process, we can see that s values between approximately 0.006 and 0.012 fall between proportions of time-selected hulls ranging from about 40-80%. Its more easily understood just by looking at the plot.
Method 2 Select a time interval that is ecologically relevant. We are interested in daily movement (e.g. night time foraging), so a 24hr cycle is OK - on the premise that points that are close together but more than 24hrs apart are not related. If you are thinking about longer temporal patterns (e.g. season), then you need to adjust the value accordingly. If you dont have a clue and are fishing for patterns then do this:
lxy.plot.pt2ctr(es.lxy)
and then do this:
lxy.plot.sfinder(es.lxy)
then do this:
#note: 3600 = 1 hour (3600 seconds)
lxy.plot.sfinder(es.lxy, delta.t=3600*c(12,24,36,48,54,60))
Both methods support an s=0.0012 value at the scale of 24hrs. According to the manual these methods don’t necessarily always converge. Apparently that is not an issue as the methods are extremely different.
using s= 0.0012 (not really sure about this. Basing it on the the average sort of result among graphs, and retaining k = 25 (value used in the distance only method)
es.lxy <- lxy.nn.add(es.lxy, s=0.0012, k=18)
## Finding nearest neighbors for id=es (n=1873), num.parent.pts=1873,
## mode=Fixed-k, k=18, s=0.0012, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: es|vmax|s0.0012|n1873|kmax18|rmax12.9|amax149.2
##
## Done. Nearest neighbor set(s) created / updated:
## es|vmax|s0.0012|n1873|kmax18|rmax12.9|amax149.2
## Total time: 2.6 secs
this adds another NN set to db.lxy ie it includes it as another list. To view:
summary(es.lxy)
## Summary of LoCoH-xy object: es.lxy
## ***Locations
## id num.pts dups
## es 1873 223
## ***Time span
## id begin end period
## es 2016-01-15 2016-03-15 59.9 days
## ***Spatial extent
## x: 385162.4 - 386607.6
## y: 6472199.2 - 6475289.3
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## es 1800 (30min) 14.07779 0.4336227
## ***Ancilliary Variables:
## -none-
## ***ptsh s-values computed
## id k n ptsh
## es 10 200 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98
## ***Nearest-neighbor set(s):
## 1 es|vmax|s0|n1873|kmax25|rmax1.2|amax19.3
## 2 es|vmax|s0.0012|n1873|kmax18|rmax12.9|amax149.2
Note the huge difference in the rmax and amax values (perhaps better to use these methods than fixed k)
At this stage selecting k=18 and s=0.0012
Can also calculate s in the same way that calculated k. This next section follows the method to do this. I don’t think its necessary as we have already used a decent method above but I will run through this method just to see if the choice is the same.
es.lxy <- lxy.nn.add(es.lxy, s=c(0.0001, 0.001, 0.01, 0.1), k=18)
## Finding nearest neighbors for id=es (n=1873), num.parent.pts=1873,
## mode=Fixed-k, k=18, s=1e-04, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: es|vmax|s1e-04|n1873|kmax18|rmax4.2|amax54.8
## Finding nearest neighbors for id=es (n=1873), num.parent.pts=1873,
## mode=Fixed-k, k=18, s=0.001, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: es|vmax|s0.001|n1873|kmax18|rmax11.5|amax137
## Finding nearest neighbors for id=es (n=1873), num.parent.pts=1873,
## mode=Fixed-k, k=18, s=0.01, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: es|vmax|s0.01|n1873|kmax18|rmax70.3|amax730.6
## Finding nearest neighbors for id=es (n=1873), num.parent.pts=1873,
## mode=Fixed-k, k=18, s=0.1, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: es|vmax|s0.1|n1873|kmax18|rmax702.5|amax7028
##
## Done. Nearest neighbor set(s) created / updated:
## es|vmax|s1e-04|n1873|kmax18|rmax4.2|amax54.8
## es|vmax|s0.001|n1873|kmax18|rmax11.5|amax137
## es|vmax|s0.01|n1873|kmax18|rmax70.3|amax730.6
## es|vmax|s0.1|n1873|kmax18|rmax702.5|amax7028
## Total time: 11.3 secs
lxy.plot.mtdr(es.lxy, k=18)
## Computing maximum theoretical distance over TSD for es
##
|
| | 0%
|
|============ | 17%
|
|======================= | 33%
|
|=================================== | 50%
|
|=============================================== | 67%
|
|========================================================== | 83%
|
|======================================================================| 100%
lxy.plot.tspan(es.lxy, k=18)
## Computing time span for es
##
|
| | 0%
|
|============ | 17%
|
|======================= | 33%
|
|=================================== | 50%
|
|=============================================== | 67%
|
|========================================================== | 83%
|
|======================================================================| 100%
Comment from the tutorial “These methods still leave a great deal up to the researcher, which has its pros and cons, but at least you’ve got quite a few alternatives for selecting an ideal s value for your particular purposes”. We’ll stick with our 0.0012 value for now, but we’ll need to create a new lhs object using this parameter:
es.lhs.time <- lxy.lhs(es.lxy, k=3*3:8, s=0.0012)
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## es: 223 duplicate points were randomly displaced by 1 map unit(s)
##
## es.pts1873.k9.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## es.pts1873.k12.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## es.pts1873.k15.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## es.pts1873.k18.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## es.pts1873.k21.s0.0012.kmin0
## - Unfortunately there isn't a set of nearest neighbors in lxy for this
## value of s :-( Run lxy.nn.add() and try again
##
## es.pts1873.k24.s0.0012.kmin0
## - Unfortunately there isn't a set of nearest neighbors in lxy for this
## value of s :-( Run lxy.nn.add() and try again
## The following hullsets were generated:
## es.pts1873.k9.s0.0012.kmin0
## es.pts1873.k12.s0.0012.kmin0
## es.pts1873.k15.s0.0012.kmin0
## es.pts1873.k18.s0.0012.kmin0
## The following hullsets were NOT generated because no suitable
## nearest-neighbor set was found:
## es.pts1873.k21.s0.0012.kmin0
## es.pts1873.k24.s0.0012.kmin0
## Total time: 2.4 secs
Merge the hulls into isopleths
es.lhs.time <- lhs.iso.add(es.lhs.time)
## Merging hulls into isopleths
## es.pts1873.k9.s0.0012.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## es.pts1873.k12.s0.0012.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## es.pts1873.k15.s0.0012.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## es.pts1873.k18.s0.0012.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Total time: 0.7 secs
Plot the isopleths
plot(es.lhs.time, iso=TRUE, figs.per.page=1)
When I was going through these in R I changed the figs.per.page to =1 as its too hard to see things on the screen. I’m not entirely sure that k=15 is the best but it is better than the other k’s. I think maybe it might be a good idea to play with the other parameters r and a.
Compare with time version to the original distance only method
# distance only method
plot(es.lhs.k18, iso=TRUE, figs.per.page=1)
# time method
es.lhs.time.k18 <- lhs.select(es.lhs.time, k=18)
plot(es.lhs.time.k18, iso=TRUE, figs.per.page=1)
Save the time selected hullset to use with additional work if taking a break at this point.
lhs.save(es.lhs.time.k18, dir="../data")
## LoCoH-hullset es.lhs.time.k18 saved as 'es.lhs.time.k18' to:
## C:\Users\20120252\Dropbox (Personal)\Statistics\Projects\Project - Foxes\data\es.n1873.s0.0012.k18.iso.lhs.03.RData
# calculation of area|dist only
es.isos <- isopleths(es.lhs.k18)
es.isos[[1]]@data
# calculation of area|time
es.time.isos <- isopleths(es.lhs.time.k18)
es.time.isos[[1]]@data
es.core <- es.isos[[1]][ es.isos[[1]][["iso.level"]]==0.5, ]
es.hr <- es.isos[[1]][ es.isos[[1]][["iso.level"]]==0.95, ]
plot(es.hr, border="blue")
plot(es.core, border="red", add=T)
es.time.isos <- isopleths(es.lhs.time.k15) es.time.isos[[1]]@data
Plot calculation of area|time vis
es.time.core <- es.time.isos[[1]][ es.time.isos[[1]][["iso.level"]]==0.5, ]
es.time.hr <- es.time.isos[[1]][ es.time.isos[[1]][["iso.level"]]==0.95, ]
plot(es.time.hr, border="blue")
plot(es.time.core, border="red", add=T)
see p20 in the tlocoh_tutorial.pdf (in the help file)
Reasoning for using it: The ‘a’ in a-method stands for adaptive, because this method is designed to reduce the number of neighbors used in areas where the points are thin and scattered. Neighbors are identified by summing up their cumulative distance from the parent point and stopping when you reach a. This may result in a many points being labeled as neighbors in a dense area (which is what you probably want), and just a few points in outlying areas (which is also what you want).
The workflow is the same as the k method, BUT deciding on a value of ‘a’ is not straightforward because: 1) a is a cumulative distance from the parent point to the nearest neighbors 2) if time is included, the ‘distance’ between points is the TSD space-time metric which is not a physical distance.
To assist in picking an appropriate value of ‘a’ the auto.a function is used. This computes the ‘a’ value such that p% of points get at least n nearest neighbours, where p and n are supplied by you.
So for example, if we like the results with k=15, we can use auto.a() to tell us the value of ‘a’ that will result in 98% of all points having 15 or more nearest neighbours.
es.a.lxy <- lxy.nn.add(es.lxy, s=0.0012, a=auto.a(nnn=18, ptp=0.98))
## Finding nearest neighbors for id=es (n=1873), num.parent.pts=1873,
## mode=Auto-a, auto.a=nn|0.98|18|1.05, s=0.0012, method=TSD:vmax
## - there is already a set of nearest neighbors for this set of parent
## points and value of s.
## - additional neighbors will be identified and appended as needed
## - computing auto-a...
## - found from existing NN set. Auto-a is 1988.194
## - finding an initial value of k using 30 randomly selected points...Done.
## - Initial k=68
## - computing cumulative distances for k=68
## - 68 wasn't large enough for 304 points. Computing cumulative
## distances for k=136 points
## - 112372 additional neighbors appended
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: es|vmax|s0.0012|n1873|kmax18|rmax46.3|amax1988.2
##
## Done. Nearest neighbor set(s) created / updated:
## es|vmax|s0.0012|n1873|kmax18|rmax46.3|amax1988.2
## Total time: 4 secs
summary(es.a.lxy)
## Summary of LoCoH-xy object: es.a.lxy
## ***Locations
## id num.pts dups
## es 1873 223
## ***Time span
## id begin end period
## es 2016-01-15 2016-03-15 59.9 days
## ***Spatial extent
## x: 385162.4 - 386607.6
## y: 6472199.2 - 6475289.3
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## es 1800 (30min) 14.07779 0.4336227
## ***Ancilliary Variables:
## -none-
## ***ptsh s-values computed
## id k n ptsh
## es 10 200 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98
## ***Nearest-neighbor set(s):
## 1 es|vmax|s0|n1873|kmax25|rmax1.2|amax19.3
## 2 es|vmax|s1e-04|n1873|kmax18|rmax4.2|amax54.8
## 3 es|vmax|s0.001|n1873|kmax18|rmax11.5|amax137
## 6 es|vmax|s0.0012|n1873|kmax18|rmax46.3|amax1988.2
## meth ptp nnn tct aVal
## auto.a #1 nn 0.98 18 1.05 1988.194
## 4 es|vmax|s0.01|n1873|kmax18|rmax70.3|amax730.6
## 5 es|vmax|s0.1|n1873|kmax18|rmax702.5|amax7028
This summary output tells us that for s= 0.0012, if a = 1988.2, that 98% of pts will have at least 18 nn.
You can now use this to set the range of a values to test to calculate the hullsets. For example: could test a = 1200, 1300, ……2400, then view the isopleth plots to see if happy or whether still need to fine tune things. This is really subjective, but this is actually how its done!
es.a.lxy <- lxy.nn.add(es.a.lxy, s=0.0012, a=2400)
## Finding nearest neighbors for id=es (n=1873), num.parent.pts=1873,
## mode=Fixed-a, a=2400, s=0.0012, method=TSD:vmax
## - there is already a set of nearest neighbors for this set of parent
## points and value of s.
## - additional neighbors will be identified and appended as needed
## - finding an initial value of k using 30 randomly selected points...Done.
## - Initial k=76
## - computing cumulative distances for k=76
## - 76 wasn't large enough for 16 points. Computing cumulative distances
## for k=152 points
## - 5968 additional neighbors appended
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: es|vmax|s0.0012|n1873|kmax18|rmax50.1|amax2400.2
##
## Done. Nearest neighbor set(s) created / updated:
## es|vmax|s0.0012|n1873|kmax18|rmax50.1|amax2400.2
## Total time: 1.1 secs
summary(es.a.lxy)
## Summary of LoCoH-xy object: es.a.lxy
## ***Locations
## id num.pts dups
## es 1873 223
## ***Time span
## id begin end period
## es 2016-01-15 2016-03-15 59.9 days
## ***Spatial extent
## x: 385162.4 - 386607.6
## y: 6472199.2 - 6475289.3
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## es 1800 (30min) 14.07779 0.4336227
## ***Ancilliary Variables:
## -none-
## ***ptsh s-values computed
## id k n ptsh
## es 10 200 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98
## ***Nearest-neighbor set(s):
## 1 es|vmax|s0|n1873|kmax25|rmax1.2|amax19.3
## 2 es|vmax|s1e-04|n1873|kmax18|rmax4.2|amax54.8
## 3 es|vmax|s0.001|n1873|kmax18|rmax11.5|amax137
## 6 es|vmax|s0.0012|n1873|kmax18|rmax50.1|amax2400.2
## meth ptp nnn tct aVal
## auto.a #1 nn 0.98 18 1.05 1988.194
## 4 es|vmax|s0.01|n1873|kmax18|rmax70.3|amax730.6
## 5 es|vmax|s0.1|n1873|kmax18|rmax702.5|amax7028
At this point also add the isopleths; previously we did this as a seperate step
es.lhs.amixed <- lxy.lhs(es.a.lxy, s=0.0012, a=12:24*100, iso.add=T)
## Using nearest-neighbor selection mode: Fixed-a
## Constructing hulls and hull metrics...
## es: 223 duplicate points were randomly displaced by 1 map unit(s)
##
## es.pts1873.a1200.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## es.pts1873.a1300.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## es.pts1873.a1400.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## es.pts1873.a1500.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## es.pts1873.a1600.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## es.pts1873.a1700.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## es.pts1873.a1800.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## es.pts1873.a1900.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## es.pts1873.a2000.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## es.pts1873.a2100.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## es.pts1873.a2200.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## es.pts1873.a2300.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## es.pts1873.a2400.s0.0012.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
## The following hullsets were generated:
## es.pts1873.a1200.s0.0012.kmin0
## es.pts1873.a1300.s0.0012.kmin0
## es.pts1873.a1400.s0.0012.kmin0
## es.pts1873.a1500.s0.0012.kmin0
## es.pts1873.a1600.s0.0012.kmin0
## es.pts1873.a1700.s0.0012.kmin0
## es.pts1873.a1800.s0.0012.kmin0
## es.pts1873.a1900.s0.0012.kmin0
## es.pts1873.a2000.s0.0012.kmin0
## es.pts1873.a2100.s0.0012.kmin0
## es.pts1873.a2200.s0.0012.kmin0
## es.pts1873.a2300.s0.0012.kmin0
## es.pts1873.a2400.s0.0012.kmin0
## Total time: 12.4 secs
plot(es.lhs.amixed, hulls=TRUE,figs.per.page=6)
plot(es.lhs.amixed, iso=TRUE, figs.per.page=6)
to try an help with interpreting the which value of a is reasonable
lhs.plot.isoarea(es.lhs.amixed)
lhs.plot.isoear(es.lhs.amixed)
This suggests that a= 1988.2 is probably OK so I will use a = 2000
plot(es.lhs.amixed, hulls=T, a=2000, allpts=T, cex.allpts=0.1, col.allpts="gray10", ufipt=F)
plot(es.lhs.amixed, iso=T, a=2000, allpts=T, cex.allpts=0.1, col.allpts="gray10", ufipt=F)
# calculation of area|time|a method
es.timea.isos <- isopleths(es.lhs.amixed, a=2000)
es.timea.isos[[1]]@data
The previous time fixed k method gave 50% as 7.5ha, 95% as 50.4ha Here we have 49ha and 60ha
Fill these data results into hr2.area1.xlsx in the atm project
Calculation of area|time|a method with pts overlay
es.timea.core <- es.timea.isos[[1]][ es.timea.isos[[1]][["iso.level"]]==0.5, ]
es.timea.hr <- es.timea.isos[[1]][ es.timea.isos[[1]][["iso.level"]]==0.95, ]
plot(es.timea.hr, border="blue")
plot(es.lhs.amixed,a=2000, allpts=T, cex.allpts=0.1, col.allpts="gray90", ufipt=F, add=T)
plot(es.timea.core, border="red", add=T)
As far as I’m aware the time data is already in local time so no transformation required
#fox.db$dt <- as.POSIXct(strptime(fox.db$DATETIME, format="%d/%m/%Y %H:%M"))
fox.hx$dt <- as.POSIXct(fox.hx$DATETIME, format="%d/%m/%Y %H:%M", tz="Australia/Perth")
hx <- fox.hx[,c("LONGITUDE","LATITUDE","dt","ANIMALID")]
#rename cols
colnames(hx)[1:4] <- c("x","y","dt","id")
#check first 4 linhx of the dataframe
hx[1:4,]
give x and y a projection This creates the first of a series of new dataframes that are joined. Pretty clunky way to do it but this is what is required in this program
#sub-df 1 latlong
hx.sp.latlong <- SpatialPoints(hx[ , c("x","y")], proj4string=CRS("+proj=longlat +ellps=WGS84"))
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
hx.sp.utm <- spTransform(hx.sp.latlong, CRS("+proj=utm +south +zone=50 +ellps=WGS84"))
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
hx.mat.utm <- coordinates(hx.sp.utm)
tail(hx.mat.utm)
## x y
## [567,] 392991.9 6474024
## [568,] 392996.8 6474018
## [569,] 392976.2 6474029
## [570,] 392982.4 6474012
## [571,] 392963.4 6473990
## [572,] 392985.9 6474022
#sub-df 2 local time - the data are already in this so just subset to follow naming format
hx.local <- as.POSIXct(hx$dt, tz="Australia/Perth")
local.tz <- "Australia/Perth"
hx.localtime <- as.POSIXct(format(hx.local, tz=local.tz), tz=local.tz)
#sub-df 3 id
hx.id <- hx[,c("id")]
#merge all the df in the correct tlocoh format and order
hx.lxy <- xyt.lxy(xy=hx.mat.utm, dt=hx.localtime, id="hx", proj4string=CRS("+proj=utm +south +zone=50 +ellps=WGS84"))#, dup.dt.check=FALSE)
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
Explore the structure of the lxy object
nrow(hx.lxy$pts)
## [1] 572
summary(hx.lxy)
## Summary of LoCoH-xy object: hx.lxy
## ***Locations
## id num.pts dups
## hx 572 3
## ***Time span
## id begin end period
## hx 2016-02-26 2016-03-16 19 days
## ***Spatial extent
## x: 391912.5 - 395440.9
## y: 6473676.3 - 6474533.8
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## hx 1800 (30min) 36.86996 0.7898341
## ***Ancilliary Variables:
## -none-
## ***Nearest-neighbor set(s):
## none saved
Plot out the movement trajectory
plot(hx.lxy)
Display the distribution of locations by date, step length, and sampling interval.
hist(hx.lxy)
Review the sampling frequency
lxy.plot.freq(hx.lxy, cp=T)
Construct a model of space-use without considering time (s=0). k=25 means that it is considering the nearest 25 points to the parent point (at this stage its completely arbitrary). As we are not considering time these points are the nearest in space and as such may not necessarily be sequential.
hx.lxy <- lxy.nn.add(hx.lxy, s=0, k=25)
## Finding nearest neighbors for id=hx (n=572), num.parent.pts=572,
## mode=Fixed-k, k=25, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: hx|vmax|s0|n572|kmax25|rmax7.2|amax110.4
##
## Done. Nearest neighbor set(s) created / updated:
## hx|vmax|s0|n572|kmax25|rmax7.2|amax110.4
## Total time: 0 secs
summary(hx.lxy)
## Summary of LoCoH-xy object: hx.lxy
## ***Locations
## id num.pts dups
## hx 572 3
## ***Time span
## id begin end period
## hx 2016-02-26 2016-03-16 19 days
## ***Spatial extent
## x: 391912.5 - 395440.9
## y: 6473676.3 - 6474533.8
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## hx 1800 (30min) 36.86996 0.7898341
## ***Ancilliary Variables:
## -none-
## ***Nearest-neighbor set(s):
## 1 hx|vmax|s0|n572|kmax25|rmax7.2|amax110.4
Save the lxy object for later analysis (when look at the time stuff)
lxy.save(hx.lxy, dir="../data")
## LoCoH-xy hx.lxy saved as hx.lxy to:
## C:\Users\20120252\Dropbox (Personal)\Statistics\Projects\Project - Foxes\data\hx.n572.2016-02-26.2016-03-16.lxy.03.RData
Make a kml to visualise the track on GoogleEarth so can get a feel for the animals movement. This is easy but produces a pretty awful result. Doesn’t appear to read the dt appropriately. Gives and enddate in 2021 Check our the t-locoh extension tutorial to see if there is a better way to do this. For some reason I cant get this to save in a folder so it will go into the script folder by default.
lxy.exp.kml(hx.lxy, 'hx.lxy.221121.kml',compress = FALSE, pt.scale = 0.25, path.lwd = 3)
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
## Reprojecting data to +proj=longlat +datum=WGS84...Done.
## Exporting locations
##
|
| | 0%
|
| | 1%
|
|= | 1%
|
|= | 2%
|
|== | 2%
|
|== | 3%
|
|=== | 4%
|
|=== | 5%
|
|==== | 5%
|
|==== | 6%
|
|===== | 6%
|
|===== | 7%
|
|===== | 8%
|
|====== | 8%
|
|====== | 9%
|
|======= | 9%
|
|======= | 10%
|
|======= | 11%
|
|======== | 11%
|
|======== | 12%
|
|========= | 12%
|
|========= | 13%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 15%
|
|=========== | 16%
|
|============ | 16%
|
|============ | 17%
|
|============ | 18%
|
|============= | 18%
|
|============= | 19%
|
|============== | 19%
|
|============== | 20%
|
|============== | 21%
|
|=============== | 21%
|
|=============== | 22%
|
|================ | 22%
|
|================ | 23%
|
|================= | 24%
|
|================= | 25%
|
|================== | 25%
|
|================== | 26%
|
|=================== | 27%
|
|=================== | 28%
|
|==================== | 28%
|
|==================== | 29%
|
|===================== | 29%
|
|===================== | 30%
|
|===================== | 31%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 32%
|
|======================= | 33%
|
|======================= | 34%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 35%
|
|========================= | 36%
|
|========================== | 37%
|
|========================== | 38%
|
|=========================== | 38%
|
|=========================== | 39%
|
|============================ | 39%
|
|============================ | 40%
|
|============================ | 41%
|
|============================= | 41%
|
|============================= | 42%
|
|============================== | 42%
|
|============================== | 43%
|
|============================== | 44%
|
|=============================== | 44%
|
|=============================== | 45%
|
|================================ | 45%
|
|================================ | 46%
|
|================================= | 47%
|
|================================= | 48%
|
|================================== | 48%
|
|================================== | 49%
|
|=================================== | 49%
|
|=================================== | 50%
|
|=================================== | 51%
|
|==================================== | 51%
|
|==================================== | 52%
|
|===================================== | 52%
|
|===================================== | 53%
|
|====================================== | 54%
|
|====================================== | 55%
|
|======================================= | 55%
|
|======================================= | 56%
|
|======================================== | 56%
|
|======================================== | 57%
|
|======================================== | 58%
|
|========================================= | 58%
|
|========================================= | 59%
|
|========================================== | 59%
|
|========================================== | 60%
|
|========================================== | 61%
|
|=========================================== | 61%
|
|=========================================== | 62%
|
|============================================ | 62%
|
|============================================ | 63%
|
|============================================= | 64%
|
|============================================= | 65%
|
|============================================== | 65%
|
|============================================== | 66%
|
|=============================================== | 66%
|
|=============================================== | 67%
|
|=============================================== | 68%
|
|================================================ | 68%
|
|================================================ | 69%
|
|================================================= | 69%
|
|================================================= | 70%
|
|================================================= | 71%
|
|================================================== | 71%
|
|================================================== | 72%
|
|=================================================== | 72%
|
|=================================================== | 73%
|
|==================================================== | 74%
|
|==================================================== | 75%
|
|===================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 77%
|
|====================================================== | 78%
|
|======================================================= | 78%
|
|======================================================= | 79%
|
|======================================================== | 79%
|
|======================================================== | 80%
|
|======================================================== | 81%
|
|========================================================= | 81%
|
|========================================================= | 82%
|
|========================================================== | 82%
|
|========================================================== | 83%
|
|========================================================== | 84%
|
|=========================================================== | 84%
|
|=========================================================== | 85%
|
|============================================================ | 85%
|
|============================================================ | 86%
|
|============================================================= | 87%
|
|============================================================= | 88%
|
|============================================================== | 88%
|
|============================================================== | 89%
|
|=============================================================== | 89%
|
|=============================================================== | 90%
|
|=============================================================== | 91%
|
|================================================================ | 91%
|
|================================================================ | 92%
|
|================================================================= | 92%
|
|================================================================= | 93%
|
|================================================================= | 94%
|
|================================================================== | 94%
|
|================================================================== | 95%
|
|=================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 97%
|
|==================================================================== | 98%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 99%
|
|======================================================================| 100%
## hx.lxy.221121.kml created
The building blocks of all T-LoCoH analyses are hulls, which are simply minimum convex polygons constructed around each point from a set of nearest neighbors. Since we’ve already identified 25 nearest neighbors for each point, we can create hulls with up to 25 nearest neighbors each. We will use the tlocoh::lxy.lhs command to create an lhs object, the next in our progression.
hx.lhs <- lxy.lhs(hx.lxy, k=3*3:8, s=0)
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## hx: 3 duplicate points were randomly displaced by 1 map unit(s)
##
## hx.pts572.k9.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## hx.pts572.k12.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## hx.pts572.k15.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## hx.pts572.k18.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## hx.pts572.k21.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## hx.pts572.k24.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## The following hullsets were generated:
## hx.pts572.k9.s0.kmin0
## hx.pts572.k12.s0.kmin0
## hx.pts572.k15.s0.kmin0
## hx.pts572.k18.s0.kmin0
## hx.pts572.k21.s0.kmin0
## hx.pts572.k24.s0.kmin0
## Total time: 0.7 secs
What we are doing here is creating 6 different hullsets with k values of 9, 12, 15, 18, 21, and 24 (note we are still setting s=0 because we are not considering the temporal component yet). It is useful to create a selection of hullsets so that we can compare them and choose the optimal one for our purposes. The downside of creating all of these extra hullsets is that it may take a little while to run. Once it is finished, we can get an idea of what areas are included in our hullsets using the tlocoh::plot command again. This time, we will specify that we want to plot the hulls and we’ll add all of the plots to a single page|or loads of pages(!) for easier comparison.
plot(hx.lhs, hulls=TRUE, figs.per.page=1) #if want multiple plots/page then increase No. ie. page = 6
Isopleths are aggregations of hulls sorted in such a way as to reveal something about space use. The default settings for tlocoh::lhs.iso.add sorts hulls according to density, so the isopleths reflect the likelihood of occurrence, which is a proxy for intensity of use. Then we can plot these (using the iso=TRUE specification instead of hulls=TRUE) to see how they compare to one another and to the hullset plots.
hx.lhs <- lhs.iso.add(hx.lhs)
## Merging hulls into isopleths
## hx.pts572.k9.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 393661.08901201998 6474454.2810678296
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## hx.pts572.k12.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## hx.pts572.k15.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## hx.pts572.k18.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## hx.pts572.k21.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## hx.pts572.k24.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Total time: 0.3 secs
plot(hx.lhs, iso=TRUE, figs.per.page=1)
plot(hx.lhs, iso=T, k=21, allpts=T, cex.allpts=0.1, col.allpts="gray80", ufipt=F)
Note: you can also produce the above plot without the pts. In this case just use: plot(es.lhs, iso=T, k=24, ufipt=F). ######ignore - I originally ran this with k=18 which looked ok mapping this iso’s but when I ran ######ignore - the plots below it looks like k=15 might be better.
Two other plots can be used to evaluate the choice of k value. The first is the isopleth area curves, which will plot the area included in a set of different isopleth levels (ranging from 0.15 to 0.95 by 0.10). We want to check these plots to make sure that there are no sharp jumps between k values that indicate that a relatively small change in k results in a large increase in included area (likely a false commission). To look at this plot, we use the tlocoh::lhs.plot.isoarea command:
lhs.plot.isoarea(hx.lhs)
There’s a bit of a jump after 15….
Next - look at the edge to area ratio. We are looking to exclude k values that result in very high edge:area ratios, which are indicative of the Swiss cheese pattern (i.e., many small holes). This is particularly important at some of the isopleths associated with the core area (0.35, 0.45, 0.55) where we would expect relatively few holes.
lhs.plot.isoear(hx.lhs)
If the plots are too small in the RMarkdown window then put the code into the Console and view the plot in the plot window. Resize this area first so that the plot is nice and big. Having run all the k values multiple times k=15 is actually the best. i.e. using a larger value of k doesnt really change how many of the grey dtps are included in the hulls.
Select this value for subsequent runs and save as an object
hx.lhs.k15 <- lhs.select(hx.lhs, k=15)
lhs.save(hx.lhs.k15, dir="../data")
## LoCoH-hullset hx.lhs.k15 saved as 'hx.lhs.k15' to:
## C:\Users\20120252\Dropbox (Personal)\Statistics\Projects\Project - Foxes\data\hx.n572.s0.k15.iso.lhs.03.RData
If doing this step in another session then you need to load the lxy and lhs RData files that you saved above. Use the following syntax:
load(‘./data/es.n1873.2016-01-15.2016-03-15.lxy.03.RData’) # es.lxy #change to hx load(‘./data/es.n1873.s0.k18.iso.lhs.02.RData’) # es.lhs.k18 #change to hx
create a new nearest neighbor set with a non-zero s parameter. That is, we are now creating a UD that incorporates time. In the first plot there are points in the same general areas that are colour coded differently. This means that they were in the same area but at different times so these points are not temporally related. In the s=0 calculations above this is ignored and therefore is not ecologically very informative.
Firstly, need to select a ‘decent’ s value. To do this pick an s value such that 40-80% of the hulls are ‘time-selected.’
This is Method 1
hx.lxy <- lxy.ptsh.add(hx.lxy)
## id: hx
## Randomly selected 200 of 572 points
## Finding 10 nearest neighbors for 200 sample points
## Finding s for ptsh=0.98
## s=0.005, s=0.01, s=0.02, s=0.04, s=0.08, s=0.16,
## Finding s for ptsh=0.1 (+/- 0.01)
## s=0.0025, s=0.00125, s=0.001875, s=0.0015625, s=0.00140625, s=0.001328125,
## Finding s for ptsh=0.2 (+/- 0.01)
## s=0.0021875,
## Finding s for ptsh=0.3 (+/- 0.01)
## s=0.00375,
## Finding s for ptsh=0.4 (+/- 0.01)
## s=0.0075,
## Finding s for ptsh=0.5 (+/- 0.01)
## s=0.015, s=0.0125, s=0.01375, s=0.013125,
## Finding s for ptsh=0.6 (+/- 0.01)
## s=0.0175, s=0.01875,
## Finding s for ptsh=0.7 (+/- 0.01)
## s=0.03,
## Finding s for ptsh=0.8 (+/- 0.01)
## s=0.06, s=0.05,
## Finding s for ptsh=0.9 (+/- 0.01)
## s=0.07,
##
## Done with hx
This creates a set of 200 sample points, each with 10 nearest neighbors. This algorithm goes through a set of different s values and determines what proportion of hulls are time-selected (ptsh). Though this is a somewhat stochastic process, we can see that s values between approximately 0.01 and 0.05 fall between proportions of time-selected hulls ranging from about 40-80%. Its more easily understood just by looking at the plot.
Method 2 Select a time interval that is ecologically relevant. We are interested in daily movement (e.g. night time foraging), so a 24hr cycle is OK - on the premise that points that are close together but more than 24hrs apart are not related. If you are thinking about longer temporal patterns (e.g. season), then you need to adjust the value accordingly. If you dont have a clue and are fishing for patterns then do this:
lxy.plot.pt2ctr(hx.lxy)
and then do this:
lxy.plot.sfinder(hx.lxy)
then do this:
#note: 3600 = 1 hour (3600 seconds)
lxy.plot.sfinder(hx.lxy, delta.t=3600*c(12,24,36,48,54,60))
Both methods support an s=0.01 value at the scale of 24hrs. According to the manual these methods don’t necessarily always converge. Apparently that is not an issue as the methods are extremely different.
using s= 0.01 (actually the range was 0.01 - 0.05…..so maybe run a series of these, and retaining k = 25 (value used in the distance only method)
hx.lxy <- lxy.nn.add(hx.lxy, s=0.01, k=25)
## Finding nearest neighbors for id=hx (n=572), num.parent.pts=572,
## mode=Fixed-k, k=25, s=0.01, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: hx|vmax|s0.01|n572|kmax25|rmax234|amax2741.6
##
## Done. Nearest neighbor set(s) created / updated:
## hx|vmax|s0.01|n572|kmax25|rmax234|amax2741.6
## Total time: 0.5 secs
this adds another NN set to hx.lxy ie it includes it as another list. To view:
summary(hx.lxy)
## Summary of LoCoH-xy object: hx.lxy
## ***Locations
## id num.pts dups
## hx 572 3
## ***Time span
## id begin end period
## hx 2016-02-26 2016-03-16 19 days
## ***Spatial extent
## x: 391912.5 - 395440.9
## y: 6473676.3 - 6474533.8
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## hx 1800 (30min) 36.86996 0.7898341
## ***Ancilliary Variables:
## -none-
## ***ptsh s-values computed
## id k n ptsh
## hx 10 200 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98
## ***Nearest-neighbor set(s):
## 1 hx|vmax|s0|n572|kmax25|rmax7.2|amax110.4
## 2 hx|vmax|s0.01|n572|kmax25|rmax234|amax2741.6
Note the huge difference in the rmax and amax values (perhaps better to use these methods than fixed k)
At this stage selecting k=25 and s=0.01
Can also calculate s in the same way that calculated k. This next section follows the method to do this. I don’t think its necessary as we have already used a decent method above but I will run through this method just to see if the choice is the same.
hx.lxy <- lxy.nn.add(hx.lxy, s=c(0.0001, 0.001, 0.01, 0.1), k=25)
## Finding nearest neighbors for id=hx (n=572), num.parent.pts=572,
## mode=Fixed-k, k=25, s=1e-04, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: hx|vmax|s1e-04|n572|kmax25|rmax19.4|amax264.4
## Finding nearest neighbors for id=hx (n=572), num.parent.pts=572,
## mode=Fixed-k, k=25, s=0.001, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: hx|vmax|s0.001|n572|kmax25|rmax36.1|amax582.6
## Finding nearest neighbors for id=hx (n=572), num.parent.pts=572,
## mode=Fixed-k, k=25, s=0.01, method=TSD:vmax
## - there is already a set of nearest neighbors for this set of parent
## points and value of s.
## - enough points already saved, no need to find more
## Finding nearest neighbors for id=hx (n=572), num.parent.pts=572,
## mode=Fixed-k, k=25, s=0.1, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: hx|vmax|s0.1|n572|kmax25|rmax1848.2|amax24088
##
## Done. Nearest neighbor set(s) created / updated:
## hx|vmax|s1e-04|n572|kmax25|rmax19.4|amax264.4
## hx|vmax|s0.001|n572|kmax25|rmax36.1|amax582.6
## hx|vmax|s0.1|n572|kmax25|rmax1848.2|amax24088
## Total time: 1.5 secs
lxy.plot.mtdr(hx.lxy, k=25)
## Computing maximum theoretical distance over TSD for hx
##
|
| | 0%
|
|============== | 20%
|
|============================ | 40%
|
|========================================== | 60%
|
|======================================================== | 80%
|
|======================================================================| 100%
lxy.plot.tspan(hx.lxy, k=25)
## Computing time span for hx
##
|
| | 0%
|
|============== | 20%
|
|============================ | 40%
|
|========================================== | 60%
|
|======================================================== | 80%
|
|======================================================================| 100%
Comment from the tutorial “These methods still leave a great deal up to the researcher, which has its pros and cons, but at least you’ve got quite a few alternatives for selecting an ideal s value for your particular purposes”. We’ll stick with our 0.0012 value for now, but we’ll need to create a new lhs object using this parameter:
hx.lhs.time <- lxy.lhs(hx.lxy, k=3*3:8, s=0.01)
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## hx: 3 duplicate points were randomly displaced by 1 map unit(s)
##
## hx.pts572.k9.s0.01.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## hx.pts572.k12.s0.01.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## hx.pts572.k15.s0.01.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## hx.pts572.k18.s0.01.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## hx.pts572.k21.s0.01.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## hx.pts572.k24.s0.01.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## The following hullsets were generated:
## hx.pts572.k9.s0.01.kmin0
## hx.pts572.k12.s0.01.kmin0
## hx.pts572.k15.s0.01.kmin0
## hx.pts572.k18.s0.01.kmin0
## hx.pts572.k21.s0.01.kmin0
## hx.pts572.k24.s0.01.kmin0
## Total time: 1.1 secs
Merge the hulls into isopleths
hx.lhs.time <- lhs.iso.add(hx.lhs.time)
## Merging hulls into isopleths
## hx.pts572.k9.s0.01.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## hx.pts572.k12.s0.01.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## hx.pts572.k15.s0.01.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## hx.pts572.k18.s0.01.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## hx.pts572.k21.s0.01.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## hx.pts572.k24.s0.01.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Total time: 0.3 secs
Plot the isopleths
plot(hx.lhs.time, iso=TRUE, figs.per.page=1)
When I was going through these in R I changed the figs.per.page to =1 as its too hard to see things on the screen. I’m not entirely sure that k=15 is the best but it is better than the other k’s. I think maybe it might be a good idea to play with the other parameters r and a.
Compare with time version to the original distance only method
# distance only method
plot(hx.lhs.k15, iso=TRUE, figs.per.page=1)
# time method
hx.lhs.time.k15 <- lhs.select(hx.lhs.time, k=15)
plot(hx.lhs.time.k15, iso=TRUE, figs.per.page=1)
Save the time selected hullset to use with additional work if taking a break at this point.
lhs.save(hx.lhs.time.k15, dir="../data")
## LoCoH-hullset hx.lhs.time.k15 saved as 'hx.lhs.time.k15' to:
## C:\Users\20120252\Dropbox (Personal)\Statistics\Projects\Project - Foxes\data\hx.n572.s0.01.k15.iso.lhs.03.RData
# calculation of area|dist only
hx.isos <- isopleths(hx.lhs.k15)
hx.isos[[1]]@data
# calculation of area|time
hx.time.isos <- isopleths(hx.lhs.time.k15)
hx.time.isos[[1]]@data
hx.core <- hx.isos[[1]][ hx.isos[[1]][["iso.level"]]==0.5, ]
hx.hr <- hx.isos[[1]][ hx.isos[[1]][["iso.level"]]==0.95, ]
plot(hx.hr, border="blue")
plot(hx.core, border="red", add=T)
es.time.isos <- isopleths(es.lhs.time.k15) es.time.isos[[1]]@data
Plot calculation of area|time vis
hx.time.core <- hx.time.isos[[1]][ hx.time.isos[[1]][["iso.level"]]==0.5, ]
hx.time.hr <- hx.time.isos[[1]][ hx.time.isos[[1]][["iso.level"]]==0.95, ]
plot(hx.time.hr, border="blue")
plot(hx.time.core, border="red", add=T)
see p20 in the tlocoh_tutorial.pdf (in the help file)
Reasoning for using it: The ‘a’ in a-method stands for adaptive, because this method is designed to reduce the number of neighbours used in areas where the points are thin and scattered. Neighbours are identified by summing up their cumulative distance from the parent point and stopping when you reach a. This may result in a many points being labelled as neighbours in a dense area (which is what you probably want), and just a few points in outlying areas (which is also what you want).
The workflow is the same as the k method, BUT deciding on a value of ‘a’ is not straightforward because: 1) a is a cumulative distance from the parent point to the nearest neighbors 2) if time is included, the ‘distance’ between points is the TSD space-time metric which is not a physical distance.
To assist in picking an appropriate value of ‘a’ the auto.a function is used. This computes the ‘a’ value such that p% of points get at least n nearest neighbours, where p and n are supplied by you.
So for example, if we like the results with k=15, we can use auto.a() to tell us the value of ‘a’ that will result in 98% of all points having 15 or more nearest neighbours.
hx.a.lxy <- lxy.nn.add(hx.lxy, s=0.01, a=auto.a(nnn=15, ptp=0.98))
## Finding nearest neighbors for id=hx (n=572), num.parent.pts=572,
## mode=Auto-a, auto.a=nn|0.98|15|1.05, s=0.01, method=TSD:vmax
## - there is already a set of nearest neighbors for this set of parent
## points and value of s.
## - additional neighbors will be identified and appended as needed
## - computing auto-a...
## - found from existing NN set. Auto-a is 8253.46
## - finding an initial value of k using 30 randomly selected points...Done.
## - Initial k=31
## - computing cumulative distances for k=31
## - 31 wasn't large enough for 146 points. Computing cumulative
## distances for k=62 points
## - 6656 additional neighbors appended
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: hx|vmax|s0.01|n572|kmax25|rmax403.6|amax8254.7
##
## Done. Nearest neighbor set(s) created / updated:
## hx|vmax|s0.01|n572|kmax25|rmax403.6|amax8254.7
## Total time: 0.6 secs
summary(hx.a.lxy)
## Summary of LoCoH-xy object: hx.a.lxy
## ***Locations
## id num.pts dups
## hx 572 3
## ***Time span
## id begin end period
## hx 2016-02-26 2016-03-16 19 days
## ***Spatial extent
## x: 391912.5 - 395440.9
## y: 6473676.3 - 6474533.8
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## hx 1800 (30min) 36.86996 0.7898341
## ***Ancilliary Variables:
## -none-
## ***ptsh s-values computed
## id k n ptsh
## hx 10 200 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98
## ***Nearest-neighbor set(s):
## 1 hx|vmax|s0|n572|kmax25|rmax7.2|amax110.4
## 2 hx|vmax|s1e-04|n572|kmax25|rmax19.4|amax264.4
## 3 hx|vmax|s0.001|n572|kmax25|rmax36.1|amax582.6
## 5 hx|vmax|s0.01|n572|kmax25|rmax403.6|amax8254.7
## meth ptp nnn tct aVal
## auto.a #1 nn 0.98 15 1.05 8253.46
## 4 hx|vmax|s0.1|n572|kmax25|rmax1848.2|amax24088
This summary output tells us that for s= 0.01, if a = 8258, that 98% of pts will have at least 18 nn.
You can now use this to set the range of a values to test to calculate the hullsets. For example: could test a = 6000, 7000, ……12000, then view the isopleth plots to see if happy or whether still need to fine tune things. This is really subjective, but this is actually how its done!
hx.a.lxy <- lxy.nn.add(hx.a.lxy, s=0.01, a=12000)
## Finding nearest neighbors for id=hx (n=572), num.parent.pts=572,
## mode=Fixed-a, a=12000, s=0.01, method=TSD:vmax
## - there is already a set of nearest neighbors for this set of parent
## points and value of s.
## - additional neighbors will be identified and appended as needed
## - finding an initial value of k using 30 randomly selected points...Done.
## - Initial k=37
## - computing cumulative distances for k=37
## - 37 wasn't large enough for 14 points. Computing cumulative distances
## for k=74 points
## - 3182 additional neighbors appended
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: hx|vmax|s0.01|n572|kmax25|rmax478.4|amax12000.6
##
## Done. Nearest neighbor set(s) created / updated:
## hx|vmax|s0.01|n572|kmax25|rmax478.4|amax12000.6
## Total time: 0.6 secs
summary(hx.a.lxy)
## Summary of LoCoH-xy object: hx.a.lxy
## ***Locations
## id num.pts dups
## hx 572 3
## ***Time span
## id begin end period
## hx 2016-02-26 2016-03-16 19 days
## ***Spatial extent
## x: 391912.5 - 395440.9
## y: 6473676.3 - 6474533.8
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## hx 1800 (30min) 36.86996 0.7898341
## ***Ancilliary Variables:
## -none-
## ***ptsh s-values computed
## id k n ptsh
## hx 10 200 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98
## ***Nearest-neighbor set(s):
## 1 hx|vmax|s0|n572|kmax25|rmax7.2|amax110.4
## 2 hx|vmax|s1e-04|n572|kmax25|rmax19.4|amax264.4
## 3 hx|vmax|s0.001|n572|kmax25|rmax36.1|amax582.6
## 5 hx|vmax|s0.01|n572|kmax25|rmax478.4|amax12000.6
## meth ptp nnn tct aVal
## auto.a #1 nn 0.98 15 1.05 8253.46
## 4 hx|vmax|s0.1|n572|kmax25|rmax1848.2|amax24088
At this point also add the isopleths; previously we did this as a seperate step
hx.lhs.amixed <- lxy.lhs(hx.a.lxy, s=0.01, a=6:12*1000, iso.add=T)
## Using nearest-neighbor selection mode: Fixed-a
## Constructing hulls and hull metrics...
## hx: 3 duplicate points were randomly displaced by 1 map unit(s)
##
## hx.pts572.a6000.s0.01.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## hx.pts572.a7000.s0.01.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## hx.pts572.a8000.s0.01.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## hx.pts572.a9000.s0.01.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## hx.pts572.a10000.s0.01.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## hx.pts572.a11000.s0.01.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## hx.pts572.a12000.s0.01.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
## The following hullsets were generated:
## hx.pts572.a6000.s0.01.kmin0
## hx.pts572.a7000.s0.01.kmin0
## hx.pts572.a8000.s0.01.kmin0
## hx.pts572.a9000.s0.01.kmin0
## hx.pts572.a10000.s0.01.kmin0
## hx.pts572.a11000.s0.01.kmin0
## hx.pts572.a12000.s0.01.kmin0
## Total time: 1.5 secs
plot(hx.lhs.amixed, hulls=TRUE,figs.per.page=6)
plot(hx.lhs.amixed, iso=TRUE, figs.per.page=6)
to try an help with interpreting which value of a is reasonable
lhs.plot.isoarea(hx.lhs.amixed)
lhs.plot.isoear(hx.lhs.amixed)
This suggests that a= 8000 is probably OK
plot(hx.lhs.amixed, hulls=T, a=8000, allpts=T, cex.allpts=0.1, col.allpts="gray10", ufipt=F)
plot(hx.lhs.amixed, iso=T, a=8000, allpts=T, cex.allpts=0.1, col.allpts="gray10", ufipt=F)
# calculation of area|time|a method
hx.timea.isos <- isopleths(hx.lhs.amixed, a=8000)
hx.timea.isos[[1]]@data
The previous time fixed k method gave 50% as 6.9ha, 95% as 82.9ha Here we have 43.8ha and 147ha
Fill these data results into hr2.area1.xlsx in the atm project
Calculation of area|time|a method with pts overlay
hx.timea.core <- hx.timea.isos[[1]][ hx.timea.isos[[1]][["iso.level"]]==0.5, ]
hx.timea.hr <- hx.timea.isos[[1]][ hx.timea.isos[[1]][["iso.level"]]==0.95, ]
plot(hx.timea.hr, border="blue")
plot(hx.lhs.amixed,a=8000, allpts=T, cex.allpts=0.1, col.allpts="gray90", ufipt=F, add=T)
plot(hx.timea.core, border="red", add=T)
As far as I’m aware the time data is already in local time so no transformation required
#fox.db$dt <- as.POSIXct(strptime(fox.db$DATETIME, format="%d/%m/%Y %H:%M"))
fox.fj$dt <- as.POSIXct(fox.fj$DATETIME, format="%d/%m/%Y %H:%M", tz="Australia/Perth")
fj <- fox.fj[,c("LONGITUDE","LATITUDE","dt","ANIMALID")]
#rename cols
colnames(fj)[1:4] <- c("x","y","dt","id")
#check first 4 linfj of the dataframe
fj[1:4,]
give x and y a projection This creates the first of a series of new dataframes that are joined. Pretty clunky way to do it but this is what is required in this program
#sub-df 1 latlong
fj.sp.latlong <- SpatialPoints(fj[ , c("x","y")], proj4string=CRS("+proj=longlat +ellps=WGS84"))
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
fj.sp.utm <- spTransform(fj.sp.latlong, CRS("+proj=utm +south +zone=50 +ellps=WGS84"))
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
fj.mat.utm <- coordinates(fj.sp.utm)
tail(fj.mat.utm)
## x y
## [7582,] 383871.5 6474643
## [7583,] 383624.7 6474766
## [7584,] 382781.0 6475523
## [7585,] 382777.3 6475531
## [7586,] 382809.5 6475557
## [7587,] 382784.3 6475552
#sub-df 2 local time - the data are already in this so just subset to follow naming format
fj.local <- as.POSIXct(fj$dt, tz="Australia/Perth")
local.tz <- "Australia/Perth"
fj.localtime <- as.POSIXct(format(fj.local, tz=local.tz), tz=local.tz)
#sub-df 3 id
fj.id <- fj[,c("id")]
#merge all the df in the correct tlocoh format and order
fj.lxy <- xyt.lxy(xy=fj.mat.utm, dt=fj.localtime, id="fj", proj4string=CRS("+proj=utm +south +zone=50 +ellps=WGS84"))#, dup.dt.check=FALSE)
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
Explore the structure of the lxy object
nrow(fj.lxy$pts)
## [1] 7587
summary(fj.lxy)
## Summary of LoCoH-xy object: fj.lxy
## ***Locations
## id num.pts dups
## fj 7587 88
## ***Time span
## id begin end period
## fj 2015-12-20 2016-08-02 226.4 days
## ***Spatial extent
## x: 381472.5 - 388561
## y: 6461026.5 - 6479450.6
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## fj 1800 (30min) 219.3052 1.749974
## ***Ancilliary Variables:
## -none-
## ***Nearest-neighbor set(s):
## none saved
Plot out the movement trajectory
plot(fj.lxy)
Display the distribution of locations by date, step length, and sampling interval.
hist(fj.lxy)
Review the sampling frequency
lxy.plot.freq(fj.lxy, cp=T)
Construct a model of space-use without considering time (s=0). k=25 means that it is considering the nearest 25 points to the parent point (at this stage its completely arbitrary). As we are not considering time these points are the nearest in space and as such may not necessarily be sequential.
fj.lxy <- lxy.nn.add(fj.lxy, s=0, k=25)
## Finding nearest neighbors for id=fj (n=7587), num.parent.pts=7587,
## mode=Fixed-k, k=25, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: fj|vmax|s0|n7587|kmax25|rmax2.9|amax41.8
##
## Done. Nearest neighbor set(s) created / updated:
## fj|vmax|s0|n7587|kmax25|rmax2.9|amax41.8
## Total time: 0.2 secs
summary(fj.lxy)
## Summary of LoCoH-xy object: fj.lxy
## ***Locations
## id num.pts dups
## fj 7587 88
## ***Time span
## id begin end period
## fj 2015-12-20 2016-08-02 226.4 days
## ***Spatial extent
## x: 381472.5 - 388561
## y: 6461026.5 - 6479450.6
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## fj 1800 (30min) 219.3052 1.749974
## ***Ancilliary Variables:
## -none-
## ***Nearest-neighbor set(s):
## 1 fj|vmax|s0|n7587|kmax25|rmax2.9|amax41.8
Save the lxy object for later analysis (when look at the time stuff)
lxy.save(fj.lxy, dir="../data")
## LoCoH-xy fj.lxy saved as fj.lxy to:
## C:\Users\20120252\Dropbox (Personal)\Statistics\Projects\Project - Foxes\data\fj.n7587.2015-12-20.2016-08-02.lxy.03.RData
Make a kml to visualise the track on GoogleEarth so can get a feel for the animals movement. This is easy but produces a pretty awful result. Doesn’t appear to read the dt appropriately. Gives and enddate in 2021 Check our the t-locoh extension tutorial to see if there is a better way to do this. For some reason I cant get this to save in a folder so it will go into the script folder by default.
lxy.exp.kml(fj.lxy, 'fj.lxy.231121.kml',compress = FALSE, pt.scale = 0.25, path.lwd = 3)
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
## = prefer_proj): Discarded datum Unknown based on WGS84 ellipsoid in Proj4
## definition
## Reprojecting data to +proj=longlat +datum=WGS84...Done.
## Exporting locations
##
|
| | 0%
|
| | 1%
|
|= | 1%
|
|= | 2%
|
|== | 2%
|
|== | 3%
|
|== | 4%
|
|=== | 4%
|
|=== | 5%
|
|==== | 5%
|
|==== | 6%
|
|===== | 6%
|
|===== | 7%
|
|===== | 8%
|
|====== | 8%
|
|====== | 9%
|
|======= | 9%
|
|======= | 10%
|
|======= | 11%
|
|======== | 11%
|
|======== | 12%
|
|========= | 12%
|
|========= | 13%
|
|========= | 14%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 15%
|
|=========== | 16%
|
|============ | 16%
|
|============ | 17%
|
|============ | 18%
|
|============= | 18%
|
|============= | 19%
|
|============== | 19%
|
|============== | 20%
|
|============== | 21%
|
|=============== | 21%
|
|=============== | 22%
|
|================ | 22%
|
|================ | 23%
|
|================ | 24%
|
|================= | 24%
|
|================= | 25%
|
|================== | 25%
|
|================== | 26%
|
|=================== | 26%
|
|=================== | 27%
|
|=================== | 28%
|
|==================== | 28%
|
|==================== | 29%
|
|===================== | 29%
|
|===================== | 30%
|
|===================== | 31%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 32%
|
|======================= | 33%
|
|======================= | 34%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 35%
|
|========================= | 36%
|
|========================== | 36%
|
|========================== | 37%
|
|========================== | 38%
|
|=========================== | 38%
|
|=========================== | 39%
|
|============================ | 39%
|
|============================ | 40%
|
|============================ | 41%
|
|============================= | 41%
|
|============================= | 42%
|
|============================== | 42%
|
|============================== | 43%
|
|============================== | 44%
|
|=============================== | 44%
|
|=============================== | 45%
|
|================================ | 45%
|
|================================ | 46%
|
|================================= | 46%
|
|================================= | 47%
|
|================================= | 48%
|
|================================== | 48%
|
|================================== | 49%
|
|=================================== | 49%
|
|=================================== | 50%
|
|=================================== | 51%
|
|==================================== | 51%
|
|==================================== | 52%
|
|===================================== | 52%
|
|===================================== | 53%
|
|===================================== | 54%
|
|====================================== | 54%
|
|====================================== | 55%
|
|======================================= | 55%
|
|======================================= | 56%
|
|======================================== | 56%
|
|======================================== | 57%
|
|======================================== | 58%
|
|========================================= | 58%
|
|========================================= | 59%
|
|========================================== | 59%
|
|========================================== | 60%
|
|========================================== | 61%
|
|=========================================== | 61%
|
|=========================================== | 62%
|
|============================================ | 62%
|
|============================================ | 63%
|
|============================================ | 64%
|
|============================================= | 64%
|
|============================================= | 65%
|
|============================================== | 65%
|
|============================================== | 66%
|
|=============================================== | 66%
|
|=============================================== | 67%
|
|=============================================== | 68%
|
|================================================ | 68%
|
|================================================ | 69%
|
|================================================= | 69%
|
|================================================= | 70%
|
|================================================= | 71%
|
|================================================== | 71%
|
|================================================== | 72%
|
|=================================================== | 72%
|
|=================================================== | 73%
|
|=================================================== | 74%
|
|==================================================== | 74%
|
|==================================================== | 75%
|
|===================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 76%
|
|====================================================== | 77%
|
|====================================================== | 78%
|
|======================================================= | 78%
|
|======================================================= | 79%
|
|======================================================== | 79%
|
|======================================================== | 80%
|
|======================================================== | 81%
|
|========================================================= | 81%
|
|========================================================= | 82%
|
|========================================================== | 82%
|
|========================================================== | 83%
|
|========================================================== | 84%
|
|=========================================================== | 84%
|
|=========================================================== | 85%
|
|============================================================ | 85%
|
|============================================================ | 86%
|
|============================================================= | 86%
|
|============================================================= | 87%
|
|============================================================= | 88%
|
|============================================================== | 88%
|
|============================================================== | 89%
|
|=============================================================== | 89%
|
|=============================================================== | 90%
|
|=============================================================== | 91%
|
|================================================================ | 91%
|
|================================================================ | 92%
|
|================================================================= | 92%
|
|================================================================= | 93%
|
|================================================================= | 94%
|
|================================================================== | 94%
|
|================================================================== | 95%
|
|=================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 96%
|
|==================================================================== | 97%
|
|==================================================================== | 98%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 99%
|
|======================================================================| 100%
## fj.lxy.231121.kml created
The building blocks of all T-LoCoH analyses are hulls, which are simply minimum convex polygons constructed around each point from a set of nearest neighbors. Since we’ve already identified 25 nearest neighbors for each point, we can create hulls with up to 25 nearest neighbors each. We will use the tlocoh::lxy.lhs command to create an lhs object, the next in our progression.
fj.lhs <- lxy.lhs(fj.lxy, k=3*3:8, s=0)
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## fj: 88 duplicate points were randomly displaced by 1 map unit(s)
##
## fj.pts7587.k9.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## fj.pts7587.k12.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## fj.pts7587.k15.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## fj.pts7587.k18.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## fj.pts7587.k21.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
##
## fj.pts7587.k24.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## The following hullsets were generated:
## fj.pts7587.k9.s0.kmin0
## fj.pts7587.k12.s0.kmin0
## fj.pts7587.k15.s0.kmin0
## fj.pts7587.k18.s0.kmin0
## fj.pts7587.k21.s0.kmin0
## fj.pts7587.k24.s0.kmin0
## Total time: 9.7 secs
What we are doing here is creating 6 different hullsets with k values of 9, 12, 15, 18, 21, and 24 (note we are still setting s=0 because we are not considering the temporal component yet). It is useful to create a selection of hullsets so that we can compare them and choose the optimal one for our purposes. The downside of creating all of these extra hullsets is that it may take a little while to run. Once it is finished, we can get an idea of what areas are included in our hullsets using the tlocoh::plot command again. This time, we will specify that we want to plot the hulls and we’ll add all of the plots to a single page|or loads of pages(!) for easier comparison.
plot(fj.lhs, hulls=TRUE, figs.per.page=1) #if want multiple plots/page then increase No. ie. page = 6
Isopleths are aggregations of hulls sorted in such a way as to reveal something about space use. The default settings for tlocoh::lhs.iso.add sorts hulls according to density, so the isopleths reflect the likelihood of occurrence, which is a proxy for intensity of use. Then we can plot these (using the iso=TRUE specification instead of hulls=TRUE) to see how they compare to one another and to the hullset plots.
fj.lhs <- lhs.iso.add(fj.lhs)
## Merging hulls into isopleths
## fj.pts7587.k9.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 382544.39733692998 6472112.5513043003
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 382649.19913879002 6463708.5977619896
## grps.cum.union.lst[[i - 1]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 382869.86634146998 6472178.2198909903
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 384858.07792352 6474033.9346225802
## grps.cum.union.lst[[i - 1]] is invalid
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## 12 invalid polygon(s) removed
## fj.pts7587.k12.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 382438.71395682998 6472193.3637751704
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 386023.22061229002 6472313.0304025002
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 384750.47971377999 6474265.8825546801
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 382858.92891775997 6474960.5267613595
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## 1 invalid polygon(s) removed
## fj.pts7587.k15.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 382219.08231025998 6472197.8419151902
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 383172.98381191998 6463350.2769290796
## grps.cum.union.lst[[i - 1]] is invalid
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 383065.95273875003 6474832.7647335697
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## 3 invalid polygon(s) removed
## fj.pts7587.k18.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 382568.03490378999 6474889.8176405896
## grps.cum.union.lst[[i - 1]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 382855.45429100998 6472287.5938465605
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## 2 invalid polygon(s) removed
## fj.pts7587.k21.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Warning in RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid"): Too few points in
## geometry component at or near point 385503.34123235999 6474302.1764455196
## ind.grps.union.lst[[i]] is invalid
## Warning in rgeos::gUnion(grps.cum.union.lst[[i - 1]], ind.grps.union.lst[[i]], :
## Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
## fj.pts7587.k24.s0.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Total time: 4.3 secs
plot(fj.lhs, iso=TRUE, figs.per.page=1)
plot(fj.lhs, iso=T, k=21, allpts=T, cex.allpts=0.1, col.allpts="gray80", ufipt=F)
Note: you can also produce the above plot without the pts. In this case just use: plot(es.lhs, iso=T, k=24, ufipt=F). ######ignore - I originally ran this with k=18 which looked ok mapping this iso’s but when I ran ######ignore - the plots below it looks like k=15 might be better.
Two other plots can be used to evaluate the choice of k value. The first is the isopleth area curves, which will plot the area included in a set of different isopleth levels (ranging from 0.15 to 0.95 by 0.10). We want to check these plots to make sure that there are no sharp jumps between k values that indicate that a relatively small change in k results in a large increase in included area (likely a false commission). To look at this plot, we use the tlocoh::lhs.plot.isoarea command:
lhs.plot.isoarea(fj.lhs)
Hmm..this is pretty flat
Next - look at the edge to area ratio. We are looking to exclude k values that result in very high edge:area ratios, which are indicative of the Swiss cheese pattern (i.e., many small holes). This is particularly important at some of the isopleths associated with the core area (0.35, 0.45, 0.55) where we would expect relatively few holes.
lhs.plot.isoear(fj.lhs)
If the plots are too small in the RMarkdown window then put the code into the Console and view the plot in the plot window. Resize this area first so that the plot is nice and big. Having run all the k values multiple times k=15 is actually the best. i.e. using a larger value of k doesnt really change how many of the grey dtps are included in the hulls.
Select this value for subsequent runs and save as an object
fj.lhs.k15 <- lhs.select(fj.lhs, k=15)
lhs.save(fj.lhs.k15, dir="../data")
## LoCoH-hullset fj.lhs.k15 saved as 'fj.lhs.k15' to:
## C:\Users\20120252\Dropbox (Personal)\Statistics\Projects\Project - Foxes\data\fj.n7587.s0.k15.iso.lhs.03.RData
If doing this step in another session then you need to load the lxy and lhs RData files that you saved above. Use the following syntax:
load(‘./data/es.n1873.2016-01-15.2016-03-15.lxy.03.RData’) # es.lxy #change to fj load(‘./data/es.n1873.s0.k18.iso.lhs.02.RData’) # es.lhs.k18 #change to fj
create a new nearest neighbor set with a non-zero s parameter. That is, we are now creating a UD that incorporates time. In the first plot there are points in the same general areas that are colour coded differently. This means that they were in the same area but at different times so these points are not temporally related. In the s=0 calculations above this is ignored and therefore is not ecologically very informative.
Firstly, need to select a ‘decent’ s value. To do this pick an s value such that 40-80% of the hulls are ‘time-selected.’
This is Method 1
fj.lxy <- lxy.ptsh.add(fj.lxy) #proportion of time selected hulls
## id: fj
## Randomly selected 200 of 7587 points
## Finding 10 nearest neighbors for 200 sample points
## Finding s for ptsh=0.98
## s=0.005, s=0.01, s=0.02, s=0.04, s=0.08, s=0.16, s=0.32,
## Finding s for ptsh=0.1 (+/- 0.01)
## s=0.0025, s=0.00125, s=0.000625,
## Finding s for ptsh=0.2 (+/- 0.01)
## s=0.00375,
## Finding s for ptsh=0.3 (+/- 0.01)
## s=0.015, s=0.0125, s=0.01125,
## Finding s for ptsh=0.4 (+/- 0.01)
## Finding s for ptsh=0.5 (+/- 0.01)
## s=0.03, s=0.035, s=0.0325, s=0.03375,
## Finding s for ptsh=0.6 (+/- 0.01)
## s=0.06, s=0.05, s=0.045,
## Finding s for ptsh=0.7 (+/- 0.01)
## s=0.07, s=0.065,
## Finding s for ptsh=0.8 (+/- 0.01)
## Finding s for ptsh=0.9 (+/- 0.01)
## s=0.12, s=0.1, s=0.11,
##
## Done with fj
This creates a set of 200 sample points, each with 10 nearest neighbors. This algorithm goes through a set of different s values and determines what proportion of hulls are time-selected (ptsh). Though this is a somewhat stochastic process, we can see that s values between approximately 0.01 and 0.06 fall between proportions of time-selected hulls ranging from about 40-80%. Its more easily understood just by looking at the plot.
Method 2 Select a time interval that is ecologically relevant. We are interested in daily movement (e.g. night time foraging), so a 24hr cycle is OK - on the premise that points that are close together but more than 24hrs apart are not related. If you are thinking about longer temporal patterns (e.g. season), then you need to adjust the value accordingly. If you dont have a clue and are fishing for patterns then do this:
lxy.plot.pt2ctr(fj.lxy)
and then do this:
lxy.plot.sfinder(fj.lxy)
then do this:
#note: 3600 = 1 hour (3600 seconds)
lxy.plot.sfinder(fj.lxy, delta.t=3600*c(12,24,36,48,54,60))
Both methods support an s=0.05 to 0.06 value at the scale of 24hrs. According to the manual these methods don’t necessarily always converge. Apparently that is not an issue as the methods are extremely different.
using s= 0.05 (actually the range was 0.01 - 0.06…..so maybe run a series of these, and retaining k = 25 (value used in the distance only method)
fj.lxy <- lxy.nn.add(fj.lxy, s=0.05, k=25)
## Finding nearest neighbors for id=fj (n=7587), num.parent.pts=7587,
## mode=Fixed-k, k=25, s=0.05, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: fj|vmax|s0.05|n7587|kmax25|rmax2047.5|amax26619.7
##
## Done. Nearest neighbor set(s) created / updated:
## fj|vmax|s0.05|n7587|kmax25|rmax2047.5|amax26619.7
## Total time: 29.9 secs
this adds another NN set to fj.lxy ie it includes it as another list. To view:
summary(fj.lxy)
## Summary of LoCoH-xy object: fj.lxy
## ***Locations
## id num.pts dups
## fj 7587 88
## ***Time span
## id begin end period
## fj 2015-12-20 2016-08-02 226.4 days
## ***Spatial extent
## x: 381472.5 - 388561
## y: 6461026.5 - 6479450.6
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## fj 1800 (30min) 219.3052 1.749974
## ***Ancilliary Variables:
## -none-
## ***ptsh s-values computed
## id k n ptsh
## fj 10 200 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98
## ***Nearest-neighbor set(s):
## 1 fj|vmax|s0|n7587|kmax25|rmax2.9|amax41.8
## 2 fj|vmax|s0.05|n7587|kmax25|rmax2047.5|amax26619.7
Note the huge difference in the rmax and amax values (perhaps better to use these methods than fixed k)
At this stage selecting k=25 and s=0.05
Can also calculate s in the same way that calculated k. This next section follows the method to do this. I don’t think its necessary as we have already used a decent method above but I will run through this method just to see if the choice is the same.
fj.lxy <- lxy.nn.add(fj.lxy, s=c(0.0005, 0.005, 0.05, 0.5), k=25)
## Finding nearest neighbors for id=fj (n=7587), num.parent.pts=7587,
## mode=Fixed-k, k=25, s=5e-04, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: fj|vmax|s5e-04|n7587|kmax25|rmax25.9|amax390.8
## Finding nearest neighbors for id=fj (n=7587), num.parent.pts=7587,
## mode=Fixed-k, k=25, s=0.005, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: fj|vmax|s0.005|n7587|kmax25|rmax204.8|amax2687.3
## Finding nearest neighbors for id=fj (n=7587), num.parent.pts=7587,
## mode=Fixed-k, k=25, s=0.05, method=TSD:vmax
## - there is already a set of nearest neighbors for this set of parent
## points and value of s.
## - enough points already saved, no need to find more
## Finding nearest neighbors for id=fj (n=7587), num.parent.pts=7587,
## mode=Fixed-k, k=25, s=0.5, method=TSD:vmax
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: fj|vmax|s0.5|n7587|kmax25|rmax20474.7|amax266171.3
##
## Done. Nearest neighbor set(s) created / updated:
## fj|vmax|s5e-04|n7587|kmax25|rmax25.9|amax390.8
## fj|vmax|s0.005|n7587|kmax25|rmax204.8|amax2687.3
## fj|vmax|s0.5|n7587|kmax25|rmax20474.7|amax266171.3
## Total time: 2 mins
lxy.plot.mtdr(fj.lxy, k=25)
## Computing maximum theoretical distance over TSD for fj
##
|
| | 0%
|
|============== | 20%
|
|============================ | 40%
|
|========================================== | 60%
|
|======================================================== | 80%
|
|======================================================================| 100%
lxy.plot.tspan(fj.lxy, k=25)
## Computing time span for fj
##
|
| | 0%
|
|============== | 20%
|
|============================ | 40%
|
|========================================== | 60%
|
|======================================================== | 80%
|
|======================================================================| 100%
Comment from the tutorial “These methods still leave a great deal up to the researcher, which has its pros and cons, but at least you’ve got quite a few alternatives for selecting an ideal s value for your particular purposes”. We’ll stick with our 0.0012 value for now, but we’ll need to create a new lhs object using this parameter:
fj.lhs.time <- lxy.lhs(fj.lxy, k=3*3:8, s=0.05)
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## fj: 88 duplicate points were randomly displaced by 1 map unit(s)
##
## fj.pts7587.k9.s0.05.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## fj.pts7587.k12.s0.05.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## fj.pts7587.k15.s0.05.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## fj.pts7587.k18.s0.05.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## fj.pts7587.k21.s0.05.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
##
## fj.pts7587.k24.s0.05.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## The following hullsets were generated:
## fj.pts7587.k9.s0.05.kmin0
## fj.pts7587.k12.s0.05.kmin0
## fj.pts7587.k15.s0.05.kmin0
## fj.pts7587.k18.s0.05.kmin0
## fj.pts7587.k21.s0.05.kmin0
## fj.pts7587.k24.s0.05.kmin0
## Total time: 26.7 secs
Merge the hulls into isopleths
fj.lhs.time <- lhs.iso.add(fj.lhs.time)
## Merging hulls into isopleths
## fj.pts7587.k9.s0.05.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## fj.pts7587.k12.s0.05.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## fj.pts7587.k15.s0.05.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## fj.pts7587.k18.s0.05.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## fj.pts7587.k21.s0.05.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## fj.pts7587.k24.s0.05.kmin0
## Sorting hulls by area...Done.
## Unioning hulls
##
|
| | 0%
|
|++++++++++ | 20%
|
|++++++++++++++++++++ | 40%
|
|+++++++++++++++++++++++++++++ | 60%
|
|+++++++++++++++++++++++++++++++++++++++ | 80%
|
|+++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Total time: 2.4 secs
Plot the isopleths
plot(fj.lhs.time, iso=TRUE, figs.per.page=1)
When I was going through these in R I changed the figs.per.page to =1 as its too hard to see things on the screen. I’m not entirely sure that k=15 is the best but it is better than the other k’s. I think maybe it might be a good idea to play with the other parameters r and a.
Compare with time version to the original distance only method
# distance only method
plot(fj.lhs.k15, iso=TRUE, figs.per.page=1)
# time method
fj.lhs.time.k15 <- lhs.select(fj.lhs.time, k=15)
plot(fj.lhs.time.k15, iso=TRUE, figs.per.page=1)
Save the time selected hullset to use with additional work if taking a break at this point.
lhs.save(fj.lhs.time.k15, dir="../data")
## LoCoH-hullset fj.lhs.time.k15 saved as 'fj.lhs.time.k15' to:
## C:\Users\20120252\Dropbox (Personal)\Statistics\Projects\Project - Foxes\data\fj.n7587.s0.05.k15.iso.lhs.03.RData
# calculation of area|dist only
fj.isos <- isopleths(fj.lhs.k15)
fj.isos[[1]]@data
# calculation of area|time
fj.time.isos <- isopleths(fj.lhs.time.k15)
fj.time.isos[[1]]@data
fj.core <- fj.isos[[1]][ fj.isos[[1]][["iso.level"]]==0.5, ]
fj.hr <- fj.isos[[1]][ fj.isos[[1]][["iso.level"]]==0.95, ]
plot(fj.hr, border="blue")
plot(fj.core, border="red", add=T)
es.time.isos <- isopleths(es.lhs.time.k15) es.time.isos[[1]]@data
Plot calculation of area|time vis
fj.time.core <- fj.time.isos[[1]][ fj.time.isos[[1]][["iso.level"]]==0.5, ]
fj.time.hr <- fj.time.isos[[1]][ fj.time.isos[[1]][["iso.level"]]==0.95, ]
plot(fj.time.hr, border="blue")
plot(fj.time.core, border="red", add=T)
see p20 in the tlocoh_tutorial.pdf (in the help file)
Reasoning for using it: The ‘a’ in a-method stands for adaptive, because this method is designed to reduce the number of neighbours used in areas where the points are thin and scattered. Neighbours are identified by summing up their cumulative distance from the parent point and stopping when you reach a. This may result in a many points being labelled as neighbours in a dense area (which is what you probably want), and just a few points in outlying areas (which is also what you want).
The workflow is the same as the k method, BUT deciding on a value of ‘a’ is not straightforward because: 1) a is a cumulative distance from the parent point to the nearest neighbors 2) if time is included, the ‘distance’ between points is the TSD space-time metric which is not a physical distance.
To assist in picking an appropriate value of ‘a’ the auto.a function is used. This computes the ‘a’ value such that p% of points get at least n nearest neighbours, where p and n are supplied by you.
So for example, if we like the results with k=15, we can use auto.a() to tell us the value of ‘a’ that will result in 98% of all points having 15 or more nearest neighbours.
fj.a.lxy <- lxy.nn.add(fj.lxy, s=0.05, a=auto.a(nnn=15, ptp=0.98))
## Finding nearest neighbors for id=fj (n=7587), num.parent.pts=7587,
## mode=Auto-a, auto.a=nn|0.98|15|1.05, s=0.05, method=TSD:vmax
## - there is already a set of nearest neighbors for this set of parent
## points and value of s.
## - additional neighbors will be identified and appended as needed
## - computing auto-a...
## - found from existing NN set. Auto-a is 34346.64
## - finding an initial value of k using 30 randomly selected points...Done.
## - Initial k=24
## - computing cumulative distances for k=24
## - 24 wasn't large enough for 682 points. Computing cumulative
## distances for k=48 points
## - 15686 additional neighbors appended
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: fj|vmax|s0.05|n7587|kmax25|rmax2049.7|amax34349
##
## Done. Nearest neighbor set(s) created / updated:
## fj|vmax|s0.05|n7587|kmax25|rmax2049.7|amax34349
## Total time: 5.9 secs
summary(fj.a.lxy)
## Summary of LoCoH-xy object: fj.a.lxy
## ***Locations
## id num.pts dups
## fj 7587 88
## ***Time span
## id begin end period
## fj 2015-12-20 2016-08-02 226.4 days
## ***Spatial extent
## x: 381472.5 - 388561
## y: 6461026.5 - 6479450.6
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## fj 1800 (30min) 219.3052 1.749974
## ***Ancilliary Variables:
## -none-
## ***ptsh s-values computed
## id k n ptsh
## fj 10 200 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98
## ***Nearest-neighbor set(s):
## 1 fj|vmax|s0|n7587|kmax25|rmax2.9|amax41.8
## 2 fj|vmax|s5e-04|n7587|kmax25|rmax25.9|amax390.8
## 3 fj|vmax|s0.005|n7587|kmax25|rmax204.8|amax2687.3
## 5 fj|vmax|s0.05|n7587|kmax25|rmax2049.7|amax34349
## meth ptp nnn tct aVal
## auto.a #1 nn 0.98 15 1.05 34346.64
## 4 fj|vmax|s0.5|n7587|kmax25|rmax20474.7|amax266171.3
This summary output tells us that for s= 0.05, if a = 34349, that 98% of pts will have at least 15 nn.
You can now use this to set the range of a values to test to calculate the hullsets. For example: could test a = 28000, 29000, ……36000, then view the isopleth plots to see if happy or whether still need to fine tune things. This is really subjective, but this is actually how its done!
fj.a.lxy <- lxy.nn.add(fj.a.lxy, s=0.05, a=36000)
## Finding nearest neighbors for id=fj (n=7587), num.parent.pts=7587,
## mode=Fixed-a, a=36000, s=0.05, method=TSD:vmax
## - there is already a set of nearest neighbors for this set of parent
## points and value of s.
## - additional neighbors will be identified and appended as needed
## - finding an initial value of k using 30 randomly selected points...Done.
## - Initial k=23
## - computing cumulative distances for k=23
## - 23 wasn't large enough for 322 points. Computing cumulative
## distances for k=46 points
## - 6762 additional neighbors appended
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: fj|vmax|s0.05|n7587|kmax25|rmax2061.8|amax36001
##
## Done. Nearest neighbor set(s) created / updated:
## fj|vmax|s0.05|n7587|kmax25|rmax2061.8|amax36001
## Total time: 3 secs
summary(fj.a.lxy)
## Summary of LoCoH-xy object: fj.a.lxy
## ***Locations
## id num.pts dups
## fj 7587 88
## ***Time span
## id begin end period
## fj 2015-12-20 2016-08-02 226.4 days
## ***Spatial extent
## x: 381472.5 - 388561
## y: 6461026.5 - 6479450.6
## proj: +proj=utm +zone=50 +south +ellps=WGS84 +units=m +no_defs
## ***Movement properties
## id time.step.median d.bar vmax
## fj 1800 (30min) 219.3052 1.749974
## ***Ancilliary Variables:
## -none-
## ***ptsh s-values computed
## id k n ptsh
## fj 10 200 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98
## ***Nearest-neighbor set(s):
## 1 fj|vmax|s0|n7587|kmax25|rmax2.9|amax41.8
## 2 fj|vmax|s5e-04|n7587|kmax25|rmax25.9|amax390.8
## 3 fj|vmax|s0.005|n7587|kmax25|rmax204.8|amax2687.3
## 5 fj|vmax|s0.05|n7587|kmax25|rmax2061.8|amax36001
## meth ptp nnn tct aVal
## auto.a #1 nn 0.98 15 1.05 34346.64
## 4 fj|vmax|s0.5|n7587|kmax25|rmax20474.7|amax266171.3
At this point also add the isopleths; previously we did this as a seperate step
fj.lhs.amixed <- lxy.lhs(fj.a.lxy, s=0.05, a=28:36*1000, iso.add=T)
## Using nearest-neighbor selection mode: Fixed-a
## Constructing hulls and hull metrics...
## fj: 88 duplicate points were randomly displaced by 1 map unit(s)
##
## fj.pts7587.a28000.s0.05.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## fj.pts7587.a29000.s0.05.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## fj.pts7587.a30000.s0.05.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## fj.pts7587.a31000.s0.05.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## fj.pts7587.a32000.s0.05.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## fj.pts7587.a33000.s0.05.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## fj.pts7587.a34000.s0.05.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## fj.pts7587.a35000.s0.05.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
##
## fj.pts7587.a36000.s0.05.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## Calculating the time span of each hull...Done.
## Identifying enclosed points...Done.
## Computing density isopleths
## The following hullsets were generated:
## fj.pts7587.a28000.s0.05.kmin0
## fj.pts7587.a29000.s0.05.kmin0
## fj.pts7587.a30000.s0.05.kmin0
## fj.pts7587.a31000.s0.05.kmin0
## fj.pts7587.a32000.s0.05.kmin0
## fj.pts7587.a33000.s0.05.kmin0
## fj.pts7587.a34000.s0.05.kmin0
## fj.pts7587.a35000.s0.05.kmin0
## fj.pts7587.a36000.s0.05.kmin0
## Total time: 48 secs
plot(fj.lhs.amixed, hulls=TRUE,figs.per.page=1)
plot(fj.lhs.amixed, iso=TRUE, figs.per.page=1)
to try an help with interpreting which value of a is reasonable
lhs.plot.isoarea(fj.lhs.amixed)
lhs.plot.isoear(fj.lhs.amixed)
This suggests that a= 34000 is probably OK
plot(fj.lhs.amixed, hulls=T, a=34000, allpts=T, cex.allpts=0.1, col.allpts="gray10", ufipt=F)
plot(fj.lhs.amixed, iso=T, a=34000, allpts=T, cex.allpts=0.1, col.allpts="gray10", ufipt=F)
# calculation of area|time|a method
fj.timea.isos <- isopleths(fj.lhs.amixed, a=34000)
fj.timea.isos[[1]]@data
The previous time fixed k method gave 50% as 129.11ha, 95% as 1398.47ha Here we have 717ha and 3930ha
Fill these data results into hr2.area1.xlsx in the atm project
Calculation of area|time|a method with pts overlay
fj.timea.core <- fj.timea.isos[[1]][ fj.timea.isos[[1]][["iso.level"]]==0.5, ]
fj.timea.hr <- fj.timea.isos[[1]][ fj.timea.isos[[1]][["iso.level"]]==0.95, ]
plot(fj.timea.hr, border="blue")
plot(fj.lhs.amixed,a=34000, allpts=T, cex.allpts=0.1, col.allpts="gray90", ufipt=F, add=T)
plot(fj.timea.core, border="red", add=T)
____ Run this next section to get all the session info | citations etc.
Run this call to get all the information about the version of R running and the packages used.
devtools::session_info()
## - Session info ---------------------------------------------------------------
## setting value
## version R version 4.0.4 (2021-02-15)
## os Windows 10 x64
## system x86_64, mingw32
## ui RTerm
## language (EN)
## collate English_Australia.1252
## ctype English_Australia.1252
## tz Australia/Perth
## date 2021-11-25
##
## - Packages -------------------------------------------------------------------
## package * version date lib source
## assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.3)
## backports 1.2.1 2020-12-09 [1] CRAN (R 4.0.3)
## bit 4.0.4 2020-08-04 [1] CRAN (R 4.0.3)
## bit64 4.0.5 2020-08-30 [1] CRAN (R 4.0.3)
## bitops 1.0-7 2021-04-24 [1] CRAN (R 4.0.5)
## broom 0.7.9 2021-07-27 [1] CRAN (R 4.0.5)
## bslib 0.3.0 2021-09-02 [1] CRAN (R 4.0.5)
## cachem 1.0.6 2021-08-19 [1] CRAN (R 4.0.5)
## callr 3.7.0 2021-04-20 [1] CRAN (R 4.0.5)
## cellranger 1.1.0 2016-07-27 [1] CRAN (R 4.0.3)
## cli 3.0.1 2021-07-17 [1] CRAN (R 4.0.5)
## codetools 0.2-18 2020-11-04 [2] CRAN (R 4.0.4)
## colorspace 2.0-2 2021-06-24 [1] CRAN (R 4.0.5)
## crayon 1.4.1 2021-02-08 [1] CRAN (R 4.0.4)
## DBI 1.1.1 2021-01-15 [1] CRAN (R 4.0.3)
## dbplyr 2.1.1 2021-04-06 [1] CRAN (R 4.0.5)
## desc 1.3.0 2021-03-05 [1] CRAN (R 4.0.5)
## devtools 2.4.2 2021-06-07 [1] CRAN (R 4.0.4)
## digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.3)
## dismo * 1.3-3 2020-11-17 [1] CRAN (R 4.0.3)
## dplyr * 1.0.7 2021-06-18 [1] CRAN (R 4.0.5)
## ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.0.5)
## evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.3)
## fansi 0.5.0 2021-05-25 [1] CRAN (R 4.0.5)
## fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.0.3)
## FNN 1.1.3 2019-02-15 [1] CRAN (R 4.0.3)
## forcats * 0.5.1 2021-01-27 [1] CRAN (R 4.0.3)
## fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.3)
## generics 0.1.0 2020-10-31 [1] CRAN (R 4.0.3)
## ggmap * 3.0.0 2019-02-04 [1] CRAN (R 4.0.3)
## ggplot2 * 3.3.5 2021-06-25 [1] CRAN (R 4.0.5)
## glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.3)
## gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.3)
## haven 2.4.3 2021-08-04 [1] CRAN (R 4.0.5)
## here * 1.0.1 2020-12-13 [1] CRAN (R 4.0.3)
## highr 0.9 2021-04-16 [1] CRAN (R 4.0.5)
## hms 1.1.0 2021-05-17 [1] CRAN (R 4.0.5)
## htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.0.5)
## httr 1.4.2 2020-07-20 [1] CRAN (R 4.0.3)
## jpeg 0.1-9 2021-07-24 [1] CRAN (R 4.0.5)
## jquerylib 0.1.4 2021-04-26 [1] CRAN (R 4.0.5)
## jsonlite 1.7.2 2020-12-09 [1] CRAN (R 4.0.4)
## knitr 1.34 2021-09-09 [1] CRAN (R 4.0.5)
## lattice 0.20-41 2020-04-02 [2] CRAN (R 4.0.4)
## lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.0.4)
## lubridate * 1.7.10 2021-02-26 [1] CRAN (R 4.0.4)
## magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.3)
## memoise 2.0.0 2021-01-26 [1] CRAN (R 4.0.3)
## modelr 0.1.8 2020-05-19 [1] CRAN (R 4.0.3)
## munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.3)
## pbapply 1.5-0 2021-09-16 [1] CRAN (R 4.0.4)
## pillar 1.6.2 2021-07-29 [1] CRAN (R 4.0.5)
## pkgbuild 1.2.0 2020-12-15 [1] CRAN (R 4.0.3)
## pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.3)
## pkgload 1.2.2 2021-09-11 [1] CRAN (R 4.0.5)
## plyr 1.8.6 2020-03-03 [1] CRAN (R 4.0.3)
## png 0.1-7 2013-12-03 [1] CRAN (R 4.0.3)
## prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.3)
## processx 3.5.2 2021-04-30 [1] CRAN (R 4.0.5)
## ps 1.6.0 2021-02-28 [1] CRAN (R 4.0.4)
## purrr * 0.3.4 2020-04-17 [1] CRAN (R 4.0.3)
## R6 2.5.1 2021-08-19 [1] CRAN (R 4.0.5)
## raster * 3.4-13 2021-06-18 [1] CRAN (R 4.0.5)
## Rcpp 1.0.7 2021-07-07 [1] CRAN (R 4.0.5)
## readr * 2.0.1 2021-08-10 [1] CRAN (R 4.0.5)
## readxl 1.3.1 2019-03-13 [1] CRAN (R 4.0.3)
## remotes 2.4.0 2021-06-02 [1] CRAN (R 4.0.5)
## reprex 2.0.1 2021-08-05 [1] CRAN (R 4.0.5)
## rgdal * 1.5-27 2021-09-16 [1] CRAN (R 4.0.4)
## rgeos 0.5-7 2021-09-07 [1] CRAN (R 4.0.5)
## RgoogleMaps 1.4.5.3 2020-02-12 [1] CRAN (R 4.0.3)
## rjson 0.2.20 2018-06-08 [1] CRAN (R 4.0.3)
## rlang 0.4.11 2021-04-30 [1] CRAN (R 4.0.5)
## rmarkdown 2.11 2021-09-14 [1] CRAN (R 4.0.5)
## rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.0.3)
## rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.0.3)
## rvest 1.0.1 2021-07-26 [1] CRAN (R 4.0.5)
## sass 0.4.0 2021-05-12 [1] CRAN (R 4.0.5)
## scales 1.1.1 2020-05-11 [1] CRAN (R 4.0.3)
## sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.3)
## sp * 1.4-5 2021-01-10 [1] CRAN (R 4.0.3)
## stringi 1.7.4 2021-08-25 [1] CRAN (R 4.0.5)
## stringr * 1.4.0 2019-02-10 [1] CRAN (R 4.0.3)
## testthat 3.0.4 2021-07-01 [1] CRAN (R 4.0.5)
## tibble * 3.1.4 2021-08-25 [1] CRAN (R 4.0.5)
## tidyr * 1.1.3 2021-03-03 [1] CRAN (R 4.0.4)
## tidyselect 1.1.1 2021-04-30 [1] CRAN (R 4.0.5)
## tidyverse * 1.3.1 2021-04-15 [1] CRAN (R 4.0.5)
## tlocoh * 1.40.07 2019-03-04 [1] R-Forge (R 4.0.4)
## tzdb 0.1.2 2021-07-20 [1] CRAN (R 4.0.5)
## usethis 2.0.1 2021-02-10 [1] CRAN (R 4.0.4)
## utf8 1.2.2 2021-07-24 [1] CRAN (R 4.0.5)
## vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.0.5)
## vroom 1.5.5 2021-09-14 [1] CRAN (R 4.0.5)
## withr 2.4.2 2021-04-18 [1] CRAN (R 4.0.5)
## xfun 0.26 2021-09-14 [1] CRAN (R 4.0.5)
## XML 3.99-0.5 2020-07-23 [1] CRAN (R 4.0.3)
## xml2 1.3.2 2020-04-23 [1] CRAN (R 4.0.3)
## yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.3)
##
## [1] C:/Users/20120252/OneDrive - Murdoch University/Documents/R/win-library/4.0
## [2] C:/R/R-4.0.4/library
If you need to source citations for different packages then use this command. You can do multiple packages by seperating them with commas. NB. if this doesnt work for multiple pkgs use the next example:
print(citation("name of package"), style = "text")
For more than one package. Note: you’ll need session_infor() to get the pkg versions
library(purrr)
c("pkg 1", "pkg 2", "pkg 3") %>%
map(citation) %>%
print(style = "text")
Then move on to the tutorial: ../Statistics/MovEco-R-Workshop-master/MovEco-R-Workshop-master/Materials/Day4/TLoCoH_and_Beyond.html
This has the method to calculate HR isopleth sizes at 50% and 95% as well as overlap btw animals and much more.
See other references throughout the script about additional resources. I have all this information stored under ./vignettes/tlocoh