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 |
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
autocruncher(bnd, knots, k = 10, nmax = 200, xname = "x", yname = "y")
autocruncher(bnd, knots, k = 10, nmax = 200, xname = "x", yname = "y")
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 |
nmax |
If supplying |
xname |
Column name of x coordinate for the knots object |
yname |
Column name of y coordinate for the knots object |
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.
This function is based on soap.r in mgcv, Copyright Simon Wood 2006-2012. Bugs fixes added by David L Miller, 2019
# crunch_ind <- autocruncher(fsb, knots, k=30, xname="v", yname="w"), will add more crunch_ind <- autocruncher(sissabagama_lake_ls, sissabagama_lake_knots)
# crunch_ind <- autocruncher(fsb, knots, k=30, xname="v", yname="w"), will add more crunch_ind <- autocruncher(sissabagama_lake_ls, sissabagama_lake_knots)
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.
overlap_polygons
overlap_polygons
A list containing 3 sub-lists with each sub-list containing two vectors, x and y.
The x coordinates of each polygon, name needs to be x
The y coordinates of each poloygon, name needs to be y
The latitude and longitude of sampled depth derived from bathymetric map from the Wisconsin DNR for Sissabagama Lake in northern Wisconsin.
sissabagama_bath
sissabagama_bath
A dataframe containing 445 rows and 3 variables:
The longitude of each sample
The latitude of each sample
The latitude of each sample
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.
sissabagama_lake_grid_knots
sissabagama_lake_grid_knots
A dataframe containing 1,125 rows and 2 variables:
The longitude of each knot
The latitude of each knot
The latitude and longitude of knots evenly spaced 200 m away from each other inside Sissabagama Lake in northern Wisconsin.
sissabagama_lake_knots
sissabagama_lake_knots
A dataframe containing 420 rows and 2 variables:
The longitude of each knot
The latitude of each knot
A list with sub-lists containing the latitude and longitude of each polygon that make up Sissabagama Lake in northern Wisconsin.
sissabagama_lake_ls
sissabagama_lake_ls
A list containing 5 sub-lists with each sub-list containing two vectors, x and y.
The longitude of each polygon, name needs to be x
The latitude of each poloygon, name needs to be y
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.
sissabagama_lake_sf
sissabagama_lake_sf
Simple feature collection with 1 features and 23 fields:
POLYGON
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
soap_check( bnd, knots = NULL, data = NULL, plot = TRUE, tol = sqrt(.Machine$double.eps), x_name = "x", y_name = "y" )
soap_check( bnd, knots = NULL, data = NULL, plot = TRUE, tol = sqrt(.Machine$double.eps), x_name = "x", y_name = "y" )
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 |
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 |
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.
# library(mgcv) # fsb <- list(fs.boundary()) # soap_check(fsb) soap_check(sissabagama_lake_ls)
# library(mgcv) # fsb <- list(fs.boundary()) # soap_check(fsb) soap_check(sissabagama_lake_ls)