dnb: Search Neighbours in Time and Space Within Specified Ranges

View source: R/dnb.R

dnbR Documentation

Search Neighbours in Time and Space Within Specified Ranges

Description

A brute force neighbor search implementation to identify observed data points within a given distance around location and time interval.

Usage

dnb(query, obs, th, future=TRUE)

Arguments

query

a vector; the x, y coordinates and the time stamp of the query point

obs

a matrix; the x, y coordinates and time stamps of the spatiotemporal locations

th

a vector; the distance threshold and time lag

future

logical, whether include observed spatiotemporal points future in time relative to the query spatiotemporal location.

Details

Implementation involves first calculating the time lags between query point and observed data (with locational coordinates and time); for observed locations within time lag of query, the function calculates the Euclidean distances between query location and all potential neighbors and select those within specified distance threshold.

The future argument can be used to exclude data in the future in neighbor search. This is useful in an extrapolation application.

Value

A vector, row numbers in the observed data matrix, that are within the given distance threshold and time lag of the query location.

Note

For large dataset, use ANN (for spatial kriging) and Range Tree for spatiotemporal Kriging.

Author(s)

Dong Liang (dliang@umces.edu)

See Also

get.knn in FNN

Examples

data(epa_cl)
coords <- c('x','y','t')
ii <- dnb(query[1,coords],obs[,coords],c(0.1,10))

ltsk documentation built on Sept. 3, 2023, 1:06 a.m.