Calculate the maximum or minimum possible distance from a point to the edge of a given polygon.
point.poly.dist(point, poly, max = TRUE, by_element = FALSE)
A simplefeatures object of class point.
A simplefeatures object of class polygon or multipolygon.
Logical; return maximum or minimum distance? default TRUE
Logical; return total maximum or minimum, or for each input
point? default FALSE
Maximum or minimum distance between a point and a polygon.
library(sf)
polys <- st_sfc(st_polygon(list(rbind(c(0,0), c(0,1), c(1,1), c(1,0), c(0,0)))),
crs = st_crs('OGC:CRS84'))
points <- st_sfc(st_multipoint(rbind(c(.25, .5), c(.75, .5), c(.5, .5))),
crs = st_crs('OGC:CRS84'))
point.poly.dist(points, polys)
#> Loading required namespace: geosphere
#> 100135 [m]