SignalSmooth: Signal Smooth on profile

View source: R/SignalSmooth.R

SignalSmoothR Documentation

Signal Smooth on profile

Description

Smooths a cross-shore elevation profile by averaging values over a moving window.

Usage

SignalSmooth(point_elev = NA, SmoothParameter = 5)

Arguments

point_elev

Cross-shore point elevations spatial points object returned from ExtractElev.

SmoothParameter

Numeric, smoothing window length as a percentage of the cross-shore profile length (0-100). A value of zero means no smoothing, but see details below (recommended values are 5-20).

Details

A smoothed cross-shore profile is necessary for convergency of the wave model. If the bottom surface topography extracted from the TopoBathy DEM is overly rugged, the wave evolution model may produce unexpected results as users may notice wave height increasing and decreasing along the length of the profile. If this is observed try increasing the smoothing parameter or omit that section of coastline from your analysis.

Value

An object of class sf and data.frame with the added column elev_smooth of smoothed elevation values along the profile.

Examples

## Not run: 
library(MNAI.CPBT)
data(Coastline)
# Generate cross-shore profile lines along the coastline.
shoreline_points <- samplePoints(
  Coastline = Coastline,
  ShorelinePointDist = 150,
  BufferDist = 300.0,
  RadLineDist = 3.0
)

# Extract elevation values along each profile
rpath <-  system.file("extdata", "TopoBathy.tif", package = "MNAI.CPBT")
TopoBathy <- raster::raster(rpath)
cross_shore_profiles <- shoreline_points[[2]]
pt_elevs <- ExtractElev(cross_shore_profiles, TopoBathy)

# Run SignalSmooth function to smooth elevation profiles for
# wave model convergence
pt_elevs <- SignalSmooth(point_elev = pt_elevs,
SmoothParameter = 5)

# Filter to just the first cross-shore profile
cs1 <- pt_elevs[pt_elevs$line_id == 2, ]
# Filter out any NA values beyond extent of TopoBathy DEM
cs1 <- cs1[!(is.na(cs1$elev)), ]
# Plot original and smoothed values
plot(1:nrow(cs1), cs1$elev, type = 'l', xlab = 'Distance (m)',
ylab = 'Elevation (m) [CD]', main = 'Cross-Shore Profile - 2')

# Compare original elevations to smoothed values
points(1:nrow(cs1), cs1$elev_smooth, type = 'l', col='red')

## End(Not run)

essatech/MNAI.CPBT documentation built on July 1, 2023, 12:34 p.m.