tdbscan | R Documentation |
tdbscan
tdbscan(track, eps, minPts = 5, borderPoints = FALSE, maxLag = 6, minTenure)
track |
A projected Track. |
eps |
size of the epsilon neighborhood (see |
minPts |
number of minimum points in the eps region (for core points).
Default is 5 points (see |
borderPoints |
Logical; default to FALSE (see |
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. |
When maxLag is set to maxLag>N
output is the same as for dbscan.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.