lawn_nearest: Get nearest point

View source: R/nearest.R

lawn_nearestR Documentation

Get nearest point

Description

Takes a reference data-Point and a set of points to compare it against and returns the point from the set closest to the reference

Usage

lawn_nearest(point, against, lint = FALSE)

Arguments

point

The reference point, a data-Feature<(data-Point)>

against

Input point set, a data-FeatureCollection

lint

(logical) Lint or not. Uses geojsonhint. Takes up increasing time as the object to get linted increases in size, so probably use by default for small objects, but not for large if you know they are good geojson objects. Default: FALSE

Value

A data-Feature<(data-Point)>

Examples

point <- '{
  "type": "Feature",
  "properties": {
    "marker-color": "#0f0"
  },
  "geometry": {
    "type": "Point",
    "coordinates": [28.965797, 41.010086]
  }
}'
against <- '{
 "type": "FeatureCollection",
 "features": [
   {
     "type": "Feature",
     "properties": {},
     "geometry": {
       "type": "Point",
       "coordinates": [28.973865, 41.011122]
     }
   }, {
     "type": "Feature",
     "properties": {},
     "geometry": {
       "type": "Point",
       "coordinates": [28.948459, 41.024204]
     }
   }, {
     "type": "Feature",
     "properties": {},
     "geometry": {
       "type": "Point",
       "coordinates": [28.938674, 41.013324]
     }
   }
 ]
}'
lawn_nearest(point, against)

## Not run: 
lawn_nearest(point, against) %>% view

## End(Not run)

ropensci/lawn documentation built on May 18, 2022, 9:58 a.m.