Skip to contents

Projects (LAT_WGS84, LONG_WGS84) to the rotated Toronto canvas and draws one dot per incident. When eps_km and min_samples are supplied AND the dbscan package is installed, points are coloured by DBSCAN cluster label.

Usage

morie_tps_render_points(
  df,
  category = "Assault",
  eps_km = NULL,
  min_samples = 20L,
  outfile = NULL,
  show_top = 12L,
  fig_w = 12,
  fig_h = 7.5
)

Arguments

df

A TPS data.frame with columns LAT_WGS84 and LONG_WGS84.

category

Optional category label used in the title.

eps_km

DBSCAN neighbourhood radius in km. When NULL no clustering is run.

min_samples

DBSCAN minimum cluster size.

outfile

Path to write the image, or NULL to return the plot.

show_top

Cap on how many clusters appear in the legend.

fig_w, fig_h

Figure size.

Value

A ggplot (when ggplot2 is available) or invisible(NULL) for the base-R path.

Examples

set.seed(1)
df <- data.frame(LAT_WGS84 = runif(60, 43.60, 43.85),
                 LONG_WGS84 = runif(60, -79.60, -79.15))
out <- morie_tps_render_points(df, min_samples = 5L,
                               outfile = tempfile(fileext = ".png"))