nearest_gridpoint {ztoolbox}R Documentation

Calculates the nearest point on a grid to a reference point

Description

Calculates nearest point on a grid to a reference point in longitude, latitude degree decimal.

Usage

nearest_gridpoint(lon, lat, grid, measure = c("euclidian","haversine"))

Arguments

lon, lat

longitude and latitude of the reference point in degrees decimal.

grid

matrix or data.frame with at leats two columns named lon and lat. The function looks for the nearest grid point to the reference point.

measure

method for distance calculation. Currently euclidian, which is the default and haversine are possible (see details).

Details

The distance of each point on grid is calculated either as a euclidian distance, or with the Haversine Formula, which computes the great-circle distance between two points on a sphere.

Value

An list with components:

idx

index of the point nearest to coordinates lon, lat on grid.

lon

longitude of reference point on grid.

lat

latitude of reference point on grid.


[Package ztoolbox version 1.0-0 Index]