SelPoint: Select nearest point

Description Usage Arguments Details Value Author(s) Examples

View source: R/select-fields.R

Description

Select the timeseries from a "pField" object at the grid point nearest to a given pair of latitude and longitude values.

Usage

1
SelPoint(data, lat, lon, simplify = TRUE, verbose = FALSE)

Arguments

data

a "pField" object.

lat

the latitude of the requested point.

lon

the longitude of the requested point.

simplify

logical; if TRUE (the default) the result will be simplified to a "pTs" object, otherwise it will be a "pField" object with only one spatial dimension.

verbose

if TRUE, print a message with the requested and nearest found coordinates. Defaults to FALSE.

Details

This is a function in development; the current method to find the nearest grid point is to minimise the root mean square deviation between the position vectors in spherical coordinates of the requested point and all observation points in the "pField" object, which is done by calling MinimizeSpherical. In the future, a different method may be implemented for this. Note that requested lat/lon values outside the range of grid points in data will be processed with a warning.

Value

a "pTs" or "pField" (if simplify = FALSE) object with the time series at the grid point nearest to the requested point.

Author(s)

Thomas Münch

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Create some empty pField object
lat <- seq(-75, -80, -5)
lon <- c(0, 135, 215)
time <- 1 : 4

x <- pField(lat = lat, lon = lon, time = time)

# Extract grid point nearest to lat = -80, lon = 200:
SelPoint(x, lat = -80, lon = 200, verbose = TRUE)
SelPoint(x, lat = -80, lon = 200, simplify = FALSE, verbose = TRUE)

EarthSystemDiagnostics/pfields documentation built on Jan. 10, 2022, 10:37 p.m.