Package 'soapcheckr'

Title: Check knot locations used by soap film smoothers for GAMS
Description: Soapcheckr allows users to easily check if the boundary used and supplied will work when using a soap-film smoother for Generalized Addtive Models (GAMs) supported by the package {mgcv}. The package also allows for users to assess if the knots and data points they want to supply the GAM will fit within the boundary.
Authors: David L. Miller and Benjamin L. Hlina
Maintainer: David L. Miller and Benjamin L. Hlina <[email protected]>
License: GPL-3 | file LICENSE
Version: 0.1.0
Built: 2024-11-09 05:39:25 UTC
Source: https://github.com/dill/soapcheckr

Help Index


Quickly find knots that will cause issues for soap-film smoother Setting up a soap film smoother is often a hard and frustrating process. This function checks that all knots, not just one knot are within the boundary and futher enough away from the boundary to effectively use a soap-film smoother

Description

Quickly find knots that will cause issues for soap-film smoother Setting up a soap film smoother is often a hard and frustrating process. This function checks that all knots, not just one knot are within the boundary and futher enough away from the boundary to effectively use a soap-film smoother

Usage

autocruncher(bnd, knots, k = 10, nmax = 200, xname = "x", yname = "y")

Arguments

bnd

A list with sub-lists that will be the boundary the soap-film smoother will smooth in. Coordinates need to be in a reference system that has meaningful units. For example, coordinates could be in UTMs as UTMs rely on metres.

knots

A dataframe with two columns that are the coordinates of the knots that are to be supplied to the soap-film smoother. Coordinates need to be be in meaniful units. For example, coordinates could be in UTMs as UTMs rely on metres.

k

If supplying k argument to mgcv::gam(), provide that same value to autocruncher().

nmax

If supplying nmax argument to mgcv::gam(), provide that same value to autocruncher().

xname

Column name of x coordinate for the knots object

yname

Column name of y coordinate for the knots object

Value

A vector of the indices of all of the knots that either fall outside the boundary or too close to the boundary and will cause for the soap-film smoother to error.

References

This function is based on soap.r in mgcv, Copyright Simon Wood 2006-2012. Bugs fixes added by David L Miller, 2019

Examples

# crunch_ind <- autocruncher(fsb, knots, k=30, xname="v", yname="w"), will add more
crunch_ind <- autocruncher(sissabagama_lake_ls, sissabagama_lake_knots)

The boundary list of example overlapping polygons

Description

A list with sub-lists containing the x and y coordinates of 3 overlapping polygons. This list of boundaries is used as an example to demonstrate how soap_check functions when polygons overlap.

Usage

overlap_polygons

Format

A list containing 3 sub-lists with each sub-list containing two vectors, x and y.

x

The x coordinates of each polygon, name needs to be x

y

The y coordinates of each poloygon, name needs to be y


Sampled bathymetry points for Sissabagama Lake

Description

The latitude and longitude of sampled depth derived from bathymetric map from the Wisconsin DNR for Sissabagama Lake in northern Wisconsin.

Usage

sissabagama_bath

Format

A dataframe containing 445 rows and 3 variables:

x

The longitude of each sample

y

The latitude of each sample

depth

The latitude of each sample


Knots for Sissabagama Lake created through using a grid

Description

The latitude and longitude of knots evenly spaced 200 m away from each other covering the boundary box of Sissabagama lake. Knots included are outside the boundary of the lake.

Usage

sissabagama_lake_grid_knots

Format

A dataframe containing 1,125 rows and 2 variables:

lon

The longitude of each knot

lat

The latitude of each knot


Knots for Sissabagama Lake

Description

The latitude and longitude of knots evenly spaced 200 m away from each other inside Sissabagama Lake in northern Wisconsin.

Usage

sissabagama_lake_knots

Format

A dataframe containing 420 rows and 2 variables:

lon

The longitude of each knot

lat

The latitude of each knot


The boundary list of Sissabagama Lake

Description

A list with sub-lists containing the latitude and longitude of each polygon that make up Sissabagama Lake in northern Wisconsin.

Usage

sissabagama_lake_ls

Format

A list containing 5 sub-lists with each sub-list containing two vectors, x and y.

x

The longitude of each polygon, name needs to be x

y

The latitude of each poloygon, name needs to be y


Sissabagama Lake located in northern Wisconsin

Description

Sissabagama Lake located in northern Wisconsin. The original shapefile was derived from the Wisconsin DNR's watershed database. Latitude and longitude are in UTM zone 15N.

Usage

sissabagama_lake_sf

Format

Simple feature collection with 1 features and 23 fields:

geometry

POLYGON


Check if boundary, knots, and data can be modeled using a soap-film smoother

Description

Setting up a soap film smoother is often a hard and frustrating process. This function checks that the boundary, knots, and data that you feed to a soap-film smoother are “correct”. The function will plot the boundary, knots and data that are trying to be modeled to ensure that they are are appropriate

Usage

soap_check(
  bnd,
  knots = NULL,
  data = NULL,
  plot = TRUE,
  tol = sqrt(.Machine$double.eps),
  x_name = "x",
  y_name = "y"
)

Arguments

bnd

A list with sub-lists that will be the boundary the soap-film smoother will smooth in. Coordinates need to be in meaningful units. For example, coordinates could be in UTMs as UTMs rely on metres.

knots

A dataframe with two columns that are the coordinates of the knots that are to be supplied to the soap-film smoother. Coordinates need to be in meaningful units. For example, coordinates could be in UTMs as UTMs rely on metres.

data

A dataframe with two columns that are the coordinates of the data that are to be supplied to the soap-film smoother. Coordinates need to be in meaningful units. For example, coordinates could be in UTMs as UTMs rely on metres.

plot

logical if plot of boundary, knots, and/or data should be plotted. Default is TRUE

tol

Tolerance value to check if boundaries are complete polygons. Sometimes tolerance needs to be increased (e.g., tol = 1e-6)

x_name

Column name of x coordinate for the knots and/or data object

y_name

Column name of y coordinate for the knots and/or data object

Value

TRUE or FALSE depending on whether the boundary will be able to used by a soap-film smoother. Addtionally if supplying knots and/or data. It will warn the user which knots and/or data fall too close or outside the boundary.

Examples

# library(mgcv)
# fsb <- list(fs.boundary())
# soap_check(fsb)

soap_check(sissabagama_lake_ls)