merge_clusters() aggregates spatiotemporal clusters within a specified distance using the Density-based Spatial Clustering of Applications with Noise (DBSCAN) algorithm. After merging, the remaining clusters are not temporally unique.

merge_clusters(
  df,
  dt_field = NULL,
  radius = 100,
  minPts = 5,
  borderPoints = TRUE,
  keep_noise = FALSE,
  noise_threshold = 1
)

Arguments

df

a data frame created by circleclust() with a sp_temporal_cluster column and datetime column.

dt_field

POSIXct; name of datetime field.

radius

numeric; distance threshold (meters) used to aggregate clusters.

minPts

numeric; minimum number of points points required in each cluster.

borderPoints

logical; should border points be assigned to clusters. Default = TRUE. If FALSE, border points are considered noise.

keep_noise

logical; should noise points be retained? Default = FALSE.

noise_threshold

numeric; threshold value (%) to determine if noise points should be retained. If the percentage of noise points is above this value, noise points are retained and column noise is appended to the output data frame. Noise points are deleted otherwise. This argument is ignored if 'keep_noise' is set to FALSE.

Value

a data frame. The original spatiotemporal cluster values are retained in a column called sp_temporal_cluster. New spatially merged cluster values are listed under spatial_cluster.

Details

merge_clusters() spatially combines clusters based on the Euclidean distance between points. Because the Earth is sphere, the calculated distances are not exact. See here.

Examples

if (FALSE) {

merge_clusters(
     df, dt_field = NULL, radius = 100, minPts = 5, borderPoints = TRUE,
     keep_noise = FALSE, noise_threshold = 1)
}