View source: R/spatial_functions.R
st_nearest_rcpp | R Documentation |
st_nearest_feature
RcppParallel version of st_nearest_feature
st_nearest_rcpp(x, y = NULL)
x |
Object of class sf/sfc or a matrix of coordinates. If a
matrix of coordinates, use column order from |
y |
Object of class sf/sfc or a matrix of coordinates. If a
matrix of coordinates, use column order from |
Vector. Indices corresponding to row of y that is closest to each element of x.
library(sf) nc <- st_read(system.file("shape/nc.shp", package="sf")) #> Reading layer `nc' from data source #> `/Users/kbutts/Library/R/arm64/4.4/library/sf/shape/nc.shp' #> using driver `ESRI Shapefile' #> Simple feature collection with 100 features and 14 fields #> Geometry type: MULTIPOLYGON #> Dimension: XY #> Bounding box: xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965 #> Geodetic CRS: NAD27 st_nearest_rcpp(nc, nc[4:6,]) #> Warning in st_point_on_surface.sfc(x): st_point_on_surface may not give correct #> results for longitude/latitude data #> Warning in st_point_on_surface.sfc(y): st_point_on_surface may not give correct #> results for longitude/latitude data #> [1] 2 2 2 1 2 3 1 3 2 2 2 2 2 2 2 2 1 2 2 1 3 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 #> [38] 2 2 2 2 2 2 3 1 2 2 2 2 2 2 2 2 2 2 1 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 #> [75] 2 2 2 2 2 3 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.