getNearestPointOnLine: Find nearest point to lines

Description Usage Arguments Details Value

View source: R/getNearestPointOnLine.R

Description

Lines are specified as a sp::SpatialLines object. The points are a sp::SpatialPoints object. If there are multiple lines in the lines object, the nearest point might be wrong so results should be checked.

Usage

1
2
3
4
5
6
getNearestPointOnLine(
  l,
  p,
  smooth.method = c("ksmooth", "none", "gSimplify"),
  ...
)

Arguments

l

the lines as a sp::SpatialLines object.

p

the points as a sp::SpatialPoints object.

smooth.method

type of method to use to smooth the offshore line. This is needed to have the offshore points spread regularly along the line and not be affected by divots.

...

parameters to specify smoothing. If "gSimplify", tol=30 is ok. If "ksmooth", smoothness=5 is ok.

Details

Note, the maptools::snapPointsToLines() function should do this, but it is not working with the SpatialLines object produced by converting a polygon to lines. It may work fine if one converts the SpatialPolygon to a SpatialLinesDataFrame with the proper line id's.

If the line is wavey, smoothing can help find points that look more perpendicular to the coast.

Value

vector of points


UW-Upwelling-Project/imageryML documentation built on Dec. 18, 2021, 6:11 p.m.