Skip to content

Instantly share code, notes, and snippets.

@tim-salabim
Last active June 13, 2018 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tim-salabim/870f9a4af76f6dda5940e62f9e0d2209 to your computer and use it in GitHub Desktop.
Save tim-salabim/870f9a4af76f6dda5940e62f9e0d2209 to your computer and use it in GitHub Desktop.
library(osmdata)
library(mapview)
library(sf)
q0 <- opq(bbox = "Bern, Switzerland", timeout = 60)
q1 <- add_osm_feature(q0, key = 'building', value = "hospital")
x <- osmdata_sf(q1)
pols_ctr = st_centroid(x$osm_polygons)
buff = st_buffer(pols_ctr, dist = 0.0015)
fin_pols = st_union(buff) %>% st_cast("POLYGON")
mapview(fin_pols) + pols_ctr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment