spatial_clusters: Identify and plot spatial clusters from point data

Description Usage Arguments Value Author(s) Examples

View source: R/spatial_clusters.R

Description

This function identifies spatial clusters from spatial coordinates (longitude / latitude) using Kmeans clustering. The resulting object is a spatial_clusters object which can be plotted with several options.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
spatial_clusters(x, k)

## S3 method for class 'spatial_clusters'
print(x, ...)

## S3 method for class 'spatial_clusters'
plot(x, show_clusters = TRUE,
  show_points = FALSE, show_tiles = FALSE, show_density = FALSE,
  pt_col = "red", pt_alpha = 0.3, cl_col = "red", cl_alpha = 0.7,
  dens_alpha = 0.3, dens_bw = 0.005, leg_posi = c(0.1, 0.8), zoom = 13,
  ...)

Arguments

x

A matrix oar data.frame with two columns indicating longitude and latitude.

k

An integer indicating the number of clusters to be found.q

show_clusters

A logical indicating if clusters should be plotted.

show_points

A logical indicating if individual points should be plotted.

show_tiles

A logical indicating if Voronoi tesselation should be plotted.

show_density

A logical indicating if case density should be plotted.

pt_col

The color to be used for individual points.

pt_alpha

The transparency level to be used for individual points.

cl_col

The color to be used for clusters.

cl_alpha

The transparency level to be used for clusters.

dens_alpha

The transparency level to be used for case density.

dens_bw

The bandwidth to be used for case density estimation; larger values correspond to a wider kernel.

leg_posi

The (x,y) position of the legend, on a relative scale from 0 to 1.

zoom

The zoom level to be used for ggmap.

x

A spatial_clusters object.

Value

The function returns a spatial_cluster object, which is a list with the following items:

Author(s)

Thibaut Jombart (thibautjombart@gmail.com)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
if (require("outbreaks")) {

lonlat <- ebola_sim$linelist[, c(10, 11)]
head(lonlat)
nrow(lonlat)


res <- spatial_clusters(lonlat, 30)
res
plot(res)

plot(res, show_density = TRUE, show_tiles = TRUE,
     cl_alpha = .2, cl_col = "blue")

}

## End(Not run)

reconhub/epimaps documentation built on May 7, 2019, 1:30 p.m.