knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(spaceheater)
library(dplyr)

Spaceheater in general is a collection of convenience functions designed to simplify steps in spatial analysis, however the effort really started with a series of simple spatial outlier methods. Some of the methods are completely self-contained and some incorporate methods from other packages. In general, the former tend to be straightforward and simple, whereas the latter are somewhat more complex.

Sample Data and Preliminaries

The sample data used here comes from a list of US breweries, filtered to include only those which are within 150km of Portland, OR, one of the greatest beer cities in the world. The data are included with the spaceheater package, so loading should be pretty straightforward,

# Load data for breweries around Portland, OR
data("pdx_breweries", package="spaceheater")
pdx_pts1 <- pdx_breweries$geometry
class(pdx_pts1)

Alternatively, we can build the sf object from scratch. It can be tedious and annoying, but sometimes a necessary task, so

df.pdx <- pdx_breweries %>%
  dplyr::select(byname, lon, lat) %>%
  mutate(geometry = spaceheater::crd_to_points(lon, lat))

Spatial Outliers

Each of the spatial outlier methods implemented in spaceheater can be called from the basic function spatial_outliers(), which returns a list containing a vector depicting outlier status and an sf polygon representing the outlier region,

x <- spatial_outliers(pdx_pts1)


nhoteling/spaceheater documentation built on Sept. 24, 2022, 3:04 p.m.