tidyst_kcurv: Tidy and geospatial kernel summary density curvature...

tidyst_kcurvR Documentation

Tidy and geospatial kernel summary density curvature estimates

Description

Tidy and geospatial versions of kernel summary density curvature estimates for 2-dimensional data.

Usage

tidy_kcurv(data, ...)
st_kcurv(x, ...)

Arguments

data

tidy kernel density curvature estimate (output from tidy_kdde(deriv_order=2))

x

geospatial density curvature estimate (output from st_kdde(deriv_order=2))

...

other parameters in ks::kcurv function

Details

A kernel density summary curvature estimate is a modification of a kernel density curvature estimate where the matrix of second order partial derivative values is summarised as a scalar value. For details of the computation of the kernel density summary curvature estimate, see ?ks::kcurv. The bandwidth matrix of smoothing parameters is computed as in ks::kdde(deriv_order=2).

Value

The output from *_kcurv have the same structure as the input kernel density curvature estimate from *_kdde, except that estimate indicates the summary curvature values rather than the density curvature values, and that deriv_group for each of the partial derivatives is collapsed into a single grouping.

Examples

## tidy kernel summary density curvature estimate
library(ggplot2)
data(crabs, package="MASS")
crabs2 <- dplyr::select(crabs, FL, CW)
t1 <- tidy_kdde(crabs2, deriv_order=2)
t2 <- tidy_kcurv(t1)
gt1 <- ggplot(t2, aes(x=FL, y=CW)) 
gt1 + geom_contour_filled_ks(colour=1) + scale_fill_brewer(palette="Oranges")

## geospatial kernel summary density curvature estimate
data(wa)
data(grevilleasf)
hakeoides <- dplyr::filter(grevilleasf, species=="hakeoides")
s1 <- st_kdde(hakeoides, deriv_order=2)
s2 <- st_kcurv(s1)

## base R plot
xlim <- c(1.2e5, 1.1e6); ylim <- c(6.1e6, 7.2e6)
plot(wa, xlim=xlim, ylim=ylim)
plot(s2, add=TRUE)

## geom_sf plot
gs1 <- ggplot(s2) + geom_sf(data=wa, fill=NA) + ggthemes::theme_map()
gs1 + geom_sf(data=st_get_contour(s2), aes(fill=label_percent(contlabel))) +
    colorspace::scale_fill_discrete_sequential(h1=30,c1=360,c2=30) +
    coord_sf(xlim=xlim, ylim=ylim)

eks documentation built on May 29, 2024, 1:17 a.m.