sl.fillequidist: Insert Points into Line on Sphere

View source: R/sl.fillequidist.R

sl.fillequidistR Documentation

Insert Points into Line on Sphere

Description

Insert points at equidistant locations along a line on a sphere. By default (for backwards compatibility) the algorithm works in x-y-z coordinates. This means that, if more than one point is added, the points are not exactly equidistant in terms of great-circle distances after projection onto the sphere, with deviations becoming large for long lines. To obtain accurate equidistant spacing on the sphere, set method="gc".

See sl.p2p for an alternative where arbitrary fractions can be specified.

Usage

sl.fillequidist(lon, lat, np = 1, method = "xyz", return.xyz = FALSE)

Arguments

lon

a vector of length 2 with the longitudes of the start and end points of the line.

lat

a vector of length 2 with the latitudes of the start and end points of the line.

np

an integer giving the number of points to be inserted. Default is 1 (in which case the algorithm is exact even for long lines).

method

a character specifying whether points are placed equidistant in x-y-z space and then reprojected onto the sphere (method="xyz", default), or equidistant in terms of resulting great-circle distance (method="gc").

return.xyz

a logical value specifying whether to return also x-y-z coordinates of the resulting points. Default is FALSE.

Value

A list with the following elements, with the last three being optional, depending on return.xyz:

lon

a vector of length np with the longitude(s) of the inserted point(s).

lat

a vector of length np with the latitude(s) of the inserted point(s).

x

a vector of length np with the x-coordinate(s) of the inserted point(s).

y

a vector of length np with the y-coordinate(s) of the inserted point(s).

z

a vector of length np with the z-coordinate(s) of the inserted point(s).

Author(s)

Helge Goessling

See Also

sl.p2p

Examples

sl.fillequidist(c(0,10),c(0,0),np=2)
## Should return:
## $lon
## [1] 3.329563 6.670437
## 
## $lat
## [1] 0 0

sl.fillequidist(c(0,10),c(0,0),np=2,method="gc")
## Should return:
## $lon
## [1] 3.333333 6.666667
## 
## $lat
## [1] 2.345519e-15 1.174747e-15

FESOM/spheRlab documentation built on April 6, 2024, 6:52 p.m.