Makes reasonable guesses about the boundaries of the OpenStreetMap extract
mounted to the active ORS instance. ors_guess
samples points over
a specified area and tries to snap these points to the nearest defined
street. It is a simple wrapper around ors_snap
.
This function can be useful to validate an ORS setup or to find the extract area of a remote (non-official) ORS server.
Usage
ors_guess(
poly = NULL,
n = 1000,
radius = 1000,
type = "regular",
poly_fun = sf::st_convex_hull,
instance = NULL,
...
)
Arguments
- poly
[various]
An
sf/sfc
object or any object that can be parsed byst_bbox
. IfNULL
, defaults to global boundaries. Needed to narrow down the area of guessing. For best results,poly
should be as small and precise as possible.- n
[integer]
Number of points to sample. More points mean slower but more precise guess work.
- radius
[numeric]
Snapping radius. Points are only snapped to a street if the street lies within this distance to the source point.
- type
[character]
Spatial sampling type. For details, see
st_sample
.- poly_fun
[function]
Function to derive a boundary polygon from successfully snapped points. Defaults to
st_convex_hull
. Other useful functions arest_concave_hull
andst_polygonize
.- instance
[ors_instance]
Object of an OpenRouteService instance that should be used for route computations. It is recommended to use
ors_instance
to set an instance globally. This argument should only be used if activating an instance globally is not feasible.- ...
Further arguments passed to
poly_fun
Note
ors_guess
usually has to make a lot of requests.
If you are rate-limited, you are strongly advised against the usage
of this function.
Examples
if (FALSE) { # \dontrun{
bounds <- get_extract_boundaries()
bounds <- sf::st_buffer(bounds, 10000)
plot(bounds)
bounds2 <- ors_guess(bounds)
plot(bounds2, add = TRUE)
bounds3 <- ors_guess(bounds, n = 10000)
plot(bounds3, add = TRUE)
bounds4 <- ors_guess(bounds, poly_fun = sf::st_concave_hull, ratio = 0)
plot(bounds4, add = TRUE)} # }