Perform enriched query on OSM and add as new column.

enrich_osm(
dataset,
name = NULL,
key = NULL,
value = NULL,
type = "points",
measure = "spherical",
r = NULL,
kernel = "uniform",
reduce_fun = sum,
control = list(),
.verbose = TRUE,
...
)

data_enrichment(ref_data, query, colname, .verbose = TRUE)

measure_matrix(measure_name, measure_fun, ref_geometry, ftr_geometry)

control_enrich(timeout = 300, memsize = 1073741824)

## Arguments

dataset target sf dataset to enrich with this package the column name of the feature to be added target OSM feature key to add, see osmdata::add_osm_feature() target value for OSM feature key to add, see osmdata::add_osm_feature() character the osm feature type or types to consider (e.g., points, polygons), see details character the measure metric used, see details The search radius used by the kernel function. function the kernel function used, see details The aggregation function used by the kernel function to aggregate the retrieved data objects The list with configuration variables for the OSRM server. It contains timeout, defining the number of seconds before the request to OSRM times out, and memsize, defining the maximum size of the query to OSRM. bool whether to print info during enrichment Additional parameters to be passed into the OSM query, such as a user-defined kernel.

## Details

Type represents the feature type to be considered. Usually this would be points, but polygons and multipolygons are also possible. This argument can also be a vector of multiple types. Non-point types will be converted to points using the st_centroid function from the sf package (NB this does not necessarily work well for all features!). Available options are:

• points

• lines

• polygons

• multilines

• multipolygons

Measure represents the metric used to compute the distances or durations between the rows in the dataset and the OSM features. The following metrics are available in this package, assuming that the OSRM server is setup as suggested in our guide at: https://github.com/sodascience/osmenrich_docker:

• spherical

• distance_by_foot

• duration_by_foot

• distance_by_car

• duration_by_car

• distance_by_bike

• duration_by_bike

Kernel indicates the kernel function from the osmenrich package to be used to weight the objects retrieved by their distances (or durations) from the reference objects and then convert these vectors into single numbers. The simplest kernel allows the user to count the number of occurrences of reference objects within a radius r and is called kernel_uniform.

For more details see the introductory vignette of osmenrich: vignette("introduction", package = "osmenrich")

## Note

If you want to get a large number of objects make sure to set the .timeout (time before request times out) and .memsize (maxmimum size of the request) arguments for the Overpass server and set the "max-table-size" argument correctly when starting the OSRM server(s).

enrich_opq()

## Examples

if (FALSE) {
library(tidyverse)
library(sf)

# Create example dataset
sf_example <-
tribble(
~person,  ~lat,   ~lon,
"Alice",  52.12,  5.09,
"Bob",    52.13,  5.08,
) %>%
sf::st_as_sf(
coords = c("lon", "lat"),
crs = 4326
)

# Enrich data creating new column waste_baskets
sf_enriched <- sf_example %>%
enrich_osm(