Learn R Programming

lawn (version 0.1.7)

lawn_nearest: Get nearest point

Description

Takes a reference data-Point and a set of points 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
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-Point as a Feature

See Also

Other classification: lawn_jenks, lawn_quantile, lawn_reclass

Examples

Run this code
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)

Run the code above in your browser using DataLab