Skip to contents

Queries OpenStreetMap (via Overpass) for elements matching tags — points of interest, amenities, buildings, transit stops, and so on — returning them as an sf of points (ways and relations are represented by their centroid).

Usage

ox_features_from_bbox(bbox, tags)

Arguments

bbox

Numeric c(xmin, ymin, xmax, ymax) in longitude/latitude.

tags

Named list of OSM tag filters. Each element is either TRUE (key present with any value) or a character vector of allowed values, e.g. list(amenity = c("school", "hospital")).

Value

An sf of POINT features with osm_type, osm_id and one column per tag encountered.

References

osmnxr is an R port of OSMnx. If you use it, please cite:

Boeing, G. (2025). Modeling and analyzing urban networks and amenities with OSMnx. Geographical Analysis, 57(4), 567–577. doi:10.1111/gean.70009

Examples

if (FALSE) { # interactive()
bbox <- c(-34.91, -8.07, -34.87, -8.04)
ox_features_from_bbox(bbox, tags = list(amenity = "school"))
}