GetDistanceField: Calculate distance between grid points

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/distance-fields.R

Description

Calculate the distances between a specified target location and all grid points of a given "pField". The calculation is based on the function distGeo.

Usage

1
2
3
4
5
6
7
8
9
GetDistanceField(
  field,
  latlon.field = NULL,
  lat,
  lon,
  get.nearest = FALSE,
  index = NULL,
  verbose = FALSE
)

Arguments

field

a "pField" object.

latlon.field

the optional result of calling GetLatLonField for field; see details. For NULL (the default), GetLatLonField is called internally.

lat

numeric vector of length 1 with the latitude of the target location relative to which distances are to be calculated.

lon

numeric vector of length 1 with the longitude of the target location.

get.nearest

logical to specify whether the given latitude - longitude pair shall be used *as is* as the target location (FALSE), or instead the nearest grid point in field (TRUE).

index

an integer array index of the input "pField" for specifying the target location. Setting this will override any lat, lon settings, while the default NULL signals to use the specified lat, lon values.

verbose

logical; if TRUE an informative message regarding the selected target location is printed.

Details

latlon.field can be supplied for efficiency if GetDistanceField needs to be called many times, e.g., to calculate the distances from several target locations for the same coordinate field.

Value

Numeric vector with distances in km of the grid points of "field" relative to the target location following the spatial ordering of a "pField" object.

Author(s)

Thomas Münch

See Also

GetLatLonField

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
field <- pField(lat = seq(0, 90, 10), lon = c(-10, 0, 10))

d <- GetDistanceField(field, lat = 5, lon = 5, verbose = TRUE)
range(d)

d <- GetDistanceField(field, lat = 5, lon = 5,
                      get.nearest = TRUE, verbose = TRUE)
range(d)

d <- GetDistanceField(field, index = 1, verbose = TRUE)
range(d)

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