Description Usage Arguments Value Author(s) Examples
View source: R/nearest_point.R
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)
1 | nearest_point(data, x1, y1, query, x2, y2, n = 1, duplicate = FALSE)
|
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 |
y1 |
A character value specifying the variable name in |
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 |
y2 |
A character value specifying the variable name in |
n |
Number of nearest village/community locations to select. Default is 1 |
duplicate |
Logical. If TRUE, keep duplicate samples. If FALSE, remove duplicate samples. |
A data frame of selected nearest sampling village/community locations
Farah Mohamad Ibrahim <abdu.ff@gmail.com>
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.