spNearest: Detect nearest polygon (country) to point(s)

Description Usage Arguments Value Author(s) See Also Examples

View source: R/spNearest.R

Description

Finds nearest polygon (country) to point(s), useful for cases where the 'sp::over' function yields NA results. Should be used with unprojected coordinates íe. lon/lat, ideally on the WGS84 ellipsoid

Usage

1
spNearest(points, global, inc = 100)

Arguments

points

a data frame with two columns of coordinates (first longitude, then latitude), or a SpatialPoints* object.

global

a data frame with two columns of coordinates (first longitude, then latitude), or a SpatialLines* object or a SpatialPolygons* object. This represents the object onto which 'points' is mapped.

inc

a numerical value which indicates how much the entire bounding box of 'global' shoud be segmented to find nearest countries. Defaults to 100.

Value

a data frame with attributes from 'global' about nearest polygon (country) to 'points'

Author(s)

Atreya Shankar

See Also

dist2Line

Examples

1
2
3
4
5
6
7
8
## Not run: 

require(rworldmap)
require(rworldxtra)
points <- rbind(c(-81.779,52.234), c(-80.873, 51.126))
test <- demystas::spNearest(points, getMap(resolution="high"))

## End(Not run)

pik-piam/demystas documentation built on Oct. 26, 2019, 12:15 a.m.