nearest_point: Function to select nearest community to a given sampling...

Description Usage Arguments Value Author(s) Examples

View source: R/nearest_point.R

Description

Function to select nearest community to a given sampling point (usually the centroid of a square grid for CSAS or of a hexagonal grid for S3M)

Usage

1
nearest_point(data, x1, y1, query, x2, y2, n = 1, duplicate = FALSE)

Arguments

data

A matrix or data frame of input sampling locations to which nearest village locations are to be matched. Data frame should contain at least information on longitude and latitude coordinates

x1

A character value specifying the variable name in input holding the longitude information of the sampling locations

y1

A character value specifying the variable name in input holding the latitude information of the sampling locations

query

A data frame of village/community locations with at least information on longitude and latitude coordinates from which to query for nearest point

x2

A character value specifying the variable name in query holding the longitude information of the village/community locations

y2

A character value specifying the variable name in query holding the latitude information of the village/community locations

n

Number of nearest village/community locations to select. Default is 1

duplicate

Logical. If TRUE, keep duplicate samples. If FALSE, remove duplicate samples.

Value

A data frame of selected nearest sampling village/community locations

Author(s)

Farah Mohamad Ibrahim <abdu.ff@gmail.com>

Examples

1
2
3
4
5
6
# Use nearest_point() with test sampling points in Sennar
sennar <- subset(sudan01, STATE == "Sennar")
samp.points <- sp::spsample(sennar, type = "hexagonal", n = 20)
nearest_point(data = samp.points@coords, x1 = "x", y1 = "y",
              query = sennar_villages, x2 = "x", y2 = "y",
              n = 3)

validmeasures/spatialsampler documentation built on Oct. 16, 2021, 3:15 a.m.