tdbscan: tdbscan

Description Usage Arguments Note Examples

View source: R/tdbscan.R

Description

tdbscan

Usage

1
tdbscan(track, eps, minPts = 5, borderPoints = FALSE, maxLag = 6, minTenure)

Arguments

track

A projected Track.

eps

size of the epsilon neighborhood (see dbscan::dbscan() ).

minPts

number of minimum points in the eps region (for core points). Default is 5 points (see dbscan::dbscan() ).

borderPoints

Logical; default to FALSE (see dbscan::dbscan() ).

maxLag

maximum relative temporal lag (see notes). Default to 6.

minTenure

minimum time difference, in hours, between the last and the first entry a cluster. Clusters with values smaller than minTenure are discarded.

Note

When maxLag is set to maxLag>N output is the same as for dbscan.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require(tdbscan)
require(data.table)
require(magrittr)
require(ggplot2)
require(ggrepel)

# Pectoral Sandpiper
data(pesa56511)
z = tdbscan(pesa56511, eps =6600, minPts   = 8, maxLag = 6, borderPoints = TRUE )

o = cbind(sp::coordinates(pesa56511), z)
ggplot(o, aes(longitude/10000,latitude/10000,color = factor(clustID))) +
geom_path(aes(color= NULL), col = 'grey', size = .5) + 
geom_point( alpha = .5, size = 2)


# Set minTenure
z = tdbscan(pesa56511, eps =6600, minPts   = 8, maxLag = 6, borderPoints = TRUE, minTenure= 24 )
o = cbind(sp::coordinates(pesa56511), z)
ggplot(o, aes(longitude/10000,latitude/10000,color = factor(clustID))) +
geom_path(aes(color= NULL), col = 'grey', size = .5) + 
geom_point( alpha = .5, size = 2)

# z bird
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')

clustLab = o[!is.na(clustID), .(x = mean(x), y = mean(y), 
	arrival = min(time), departure = max(time)  ), by = clustID]
clustLab[, tenure := difftime(departure, arrival, units = 'hours')]
clustLab[, lab := paste("ID: ", clustID, ",", tenure, "hours")]

ggplot(o, aes(y,x, color = clustID ) )+
 geom_path(aes(color= NULL), col = 'grey', size = .5) + 
 geom_point( alpha = .5, size = 2) + 
 geom_label_repel(data = clustLab, aes(y,x, label = lab), alpha = 0.7, size = 3)

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