Skip to contents

Interpolate point depth data to a raster

Usage

interpolate_points(
  point_data,
  shoreline,
  crs,
  res = 2,
  method = "MBA",
  n = 1,
  m = 1,
  h = 8,
  print_plot = TRUE
)

Arguments

point_data

sf object of depth points or a dataframe of points with columns 'lon' and 'lat'. Must contain a "depth" column. If NULL, then contours must be provided. If NULL, then contours must be provided.

shoreline

sf object of lake shoreline.

crs

target coordinate reference system: object of class crs, or input string for st_crs

res

numeric resolution of output raster in metres.

method

character interpolation method. Options are 'MBA' (default).

n

initial size of the spline space in the hierarchical construction along the x axis. If the rectangular domain is a square, n = m = 1 is recommended. If the x axis is k times the length of the y axis, n = 1, m = k is recommended. The default is n = 1.

m

initial size of the spline space in the hierarchical construction along the y axis. If the y axis is k times the length of the x axis, m = 1, n = k is recommended. The default is m = 1.

h

Number of levels in the hierarchical construction. If, e.g., n = m = 1 and h = 8, the resulting spline surface has a coefficient grid of size \(2^h\) + 3 = 259 in each direction of the spline surface. See references for additional information.

print_plot

logical print plot of interpolated raster.

Value

SpatRaster

Examples

shoreline <- readRDS(system.file("extdata/rotoma_shoreline.rds",
package = "bathytools"))
point_data <- readRDS(system.file("extdata/depth_points.rds",
                                  package = "bathytools"))
depth_points <- generate_depth_points(shoreline = shoreline,
point_data = point_data)
#> Generating depth points... [2024-11-13 23:08:47]
#> Finished! [2024-11-13 23:08:47]
bathy <- interpolate_points(point_data = depth_points, shoreline = shoreline,
crs = 2193)
#> Interpolating to raster... [2024-11-13 23:08:47]
#> Adjusting depths >= 0 to  -0.82 m
#> Finished! [2024-11-13 23:09:04]