View source: R/hotspot_dbscan.R
| hotspot_dbscan | R Documentation |
Identify clusters of points using density-based spatial clustering and represent each cluster as a buffered convex or concave hull. Clusters are ranked by the number of points they contain.
hotspot_dbscan(
data,
eps = NULL,
min_pts = NULL,
density_adjust = 2,
hull = c("concave", "convex"),
hull_ratio = 0.75,
transform = TRUE,
quiet = FALSE,
...
)
data |
An sf::sf object containing point geometries. |
eps |
A single positive number specifying the DBSCAN neighbourhood
radius in the units of the analysis co-ordinate reference system (CRS).
If |
min_pts |
A single integer specifying the minimum number of points in
an |
density_adjust |
A single positive number controlling automatic
selection of |
hull |
The type of hull used to represent each cluster: |
hull_ratio |
For concave hulls, a number from zero to one specifying the
fraction convex. Zero produces a maximally concave hull and one produces a
convex hull. The default is |
transform |
DBSCAN uses Euclidean distances and therefore requires a
projected CRS. If |
quiet |
If |
... |
Further arguments passed to |
MULTIPOINT geometries are cast to individual points before analysis. The
output n column counts all input point coordinates intersecting each final
cluster polygon, not only points assigned to that DBSCAN cluster. DBSCAN
includes border points in clusters by default; supplying
borderPoints = FALSE through ... instead performs DBSCAN* and excludes
border points from the points used to construct the hull.
Each cluster geometry is the selected hull of all assigned points, buffered
by eps and clipped to the convex hull of all input points. Different
cluster polygons may overlap after hull construction and buffering.
An sf tibble with class hspt_s and one row per non-noise
cluster. It contains cluster, the original DBSCAN cluster identifier;
rank, the priority rank; n, the number of input point coordinates
intersecting the polygon; prop, n as a proportion of all input point
coordinates; prop_area, the polygon area as a proportion of the area
covered by a hull of the complete dataset; and geometry. The
complete-dataset hull uses the same hull, hull_ratio, buffering and
clipping rules as the cluster hulls. Since cluster polygons may overlap,
the sums of prop and prop_area can exceed one. Ranking is by decreasing
n, then increasing polygon area, then increasing cluster identifier.
When min_pts = NULL, it is calculated as
min(n, 50, max(5, ceiling(sqrt(n)))),
where n is the number of point coordinates after empty geometries have
been removed and MULTIPOINT geometries have been expanded. For datasets
with two to four coordinates, all coordinates are required. At least two
coordinates are needed for automatic selection. This rule increases the
evidence required to identify a hotspot in larger datasets, while the upper
limit prevents the required number of neighbours becoming excessively
large.
When eps = NULL, the function calculates the distance from every point to
its (min_pts - 1)th nearest other point. The median of those distances is
a typical local neighbourhood radius. The value used for clustering is
eps = median_neighbour_distance / sqrt(density_adjust).
min_pts - 1 other points are used because DBSCAN counts the focal point
itself. Since circular area is proportional to the square of its radius,
the default density_adjust = 2 searches for the required number of points
in approximately half the typical neighbourhood area, corresponding to
approximately twice the typical local point density. Larger values identify
denser concentrations; values below one allow less-dense concentrations.
Automatic values provide a starting point for exploratory analysis. DBSCAN results can be sensitive to both parameters, so users should consider whether the resulting neighbourhood size and minimum density are meaningful for their application.
# The default concave hulls require GEOS 3.11 or later.
if (utils::compareVersion(sf::sf_extSoftVersion()[["GEOS"]], "3.11.0") >= 0) {
hotspot_dbscan(memphis_robberies_jan)
}
hotspot_dbscan(
memphis_robberies_jan,
density_adjust = 3,
hull = "convex"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.