tidyst_as_kde: Tidy and geospatial quasi kernel density estimates from...

tidyst_as_kdeR Documentation

Tidy and geospatial quasi kernel density estimates from gridded data

Description

Tidy and geospatial versions of quasi kernel density estimates for 1- and 2-dimensional gridded data.

Usage

tidy_as_kde(data, density, ...)
st_as_kde(x, attrib=1, density, ...)

Arguments

data

data frame/tibble, where first d columns are evaluation points of an estimation grid, and last column is estimate value

x

sf object, where attrib is estimate value and estimation grid is rectangle polygon geometry

attrib

name or position of estimate variable. Default is 1.

density

flag to compute bona fide density. Default is TRUE.

...

other parameters

Details

If density=TRUE then all the estimate values are non-negative. If density=FALSE then the estimate values can be positive or negative.

Value

The input gridded data should be a tidy form of a complete Cartesian product that forms a regular rectangular grid with no missing values or grid points/polygons. The input is converted to a quasi density estimate so that it can be subsequently treated like an output from tidy_kde or st_kde.

Examples

## tidy quasi density estimate
library(ggplot2)
data(faithfuld, package="ggplot2")
t1 <- tidy_as_kde(faithfuld)
## probabilistic density contour levels
ggplot(t1, aes(x=eruptions, y=waiting)) + 
    geom_contour_filled_ks(colour=1, aes(fill=after_stat(contperc)))

## non-probabilistic contour levels in ggplot2::geom_contour_filled
ggplot(faithfuld, aes(x=eruptions, y=waiting, z=density)) +
    geom_contour_filled(bins=4) + 
    colorspace::scale_fill_discrete_sequential(palette="Heat")

## geospatial quasi density estimate
## see example in ? st_intergrid 

eks documentation built on June 8, 2025, 1:29 p.m.