dt2Convexhull: data.frame to data.table with column for convex hull geometry...

Description Usage Arguments Value Examples

View source: R/utils.R

Description

data.frame to data.table with column for convex hull geometry by ID

Usage

1
dt2Convexhull(d, pid, y = "y", x = "x", dt = "time", projection)

Arguments

d

a data.frame including points which belong to clusters (tdbscan output), latitude, longitude and datetime

pid

ID unique for points that belong to one cluster

y

column name (character vector). The latitude.

x

column name (character vector). The longitude.

dt

column name (character vector). datetime

projection

character vector. if missing will default to '"+proj=utm +zone=4 +datum=WGS84"' with a warning.

Value

a data.table with geometry column (convex hull polygons) and connected arrival and departure datetime

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
require(data.table)
data(zbird)
z = tdbscan(zbird, eps = 12, minPts   = 5, maxLag = 5, borderPoints = TRUE )
z = z[, clustID := factor(clustID)]

o = data.frame(zbird) %>% data.table
o = merge(z, o, by.x = 'id', by.y = 'sp.ID')

o = rbindlist(list(copy(o[, tagID := 'bird1']), copy(o[, tagID := 'bird2'])), use.names = TRUE)
o[tagID == 'bird2', x := x + 5]
o[tagID == 'bird2', x := x + 5]
o[!is.na(clustID), ID := paste0(tagID, '_', clustID)]

d = dt2Convexhull(o, pid = 'ID', projection = '+proj=utm +zone=4 +datum=WGS84')

mpio-be/tdbscan documentation built on March 10, 2021, 1:20 p.m.