I am trying to plot buildings from osm using the leaflet-package in R. Unfortunately with little success and I couldn't find a reproducible example.

In a first step, I define the bounding box and add the 'feature' building:


q1 <- getbb("steckborn, switzerland") %>%
  opq() %>%

In a next step, I pass the query to overpass and extract the polygons:

out <- osmdata_sf(q1)
poly <- out$osm_polygons

Now comes the tricky part. How can I plot them using leaflet? I tried the following:


leaflet() %>% addTiles() %>% addPolygons(lines, col = "blue")

1 Answer 1


I found a work-around on github. Someone noticed the exact same thing and it seems to be in work. I thought I post the link here and hopefully it might help someone in the future.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.