## -----------------------------------------------------------------------------
library(sf)
library(sfhotspot)
library(ggplot2)

knitr::opts_chunk$set(
  fig.align = "center",
  fig.asp = 0.7,
  fig.width = 6
)

## -----------------------------------------------------------------------------
memphis_robberies

## -----------------------------------------------------------------------------
ggplot(memphis_robberies) + 
  geom_sf(alpha = 0.1) + 
  theme_minimal()

## -----------------------------------------------------------------------------
point_counts <- hotspot_count(memphis_robberies)

point_counts

## -----------------------------------------------------------------------------
ggplot() +
  geom_sf(
    mapping = aes(fill = n),
    data = point_counts,
    alpha = 0.75,
    colour = NA
  ) +
  scale_fill_distiller(direction = 1)

## -----------------------------------------------------------------------------
robbery_kde <- hotspot_kde(memphis_robberies)

robbery_kde

## -----------------------------------------------------------------------------
ggplot() +
  geom_sf(
    mapping = aes(fill = kde),
    data = robbery_kde,
    alpha = 0.75,
    colour = NA
  ) +
  scale_fill_distiller(direction = 1)

