Skip to content

Instantly share code, notes, and snippets.

@RCura
Created January 25, 2021 17:26
Show Gist options
  • Save RCura/28250814ed96701f51bee9042f64c177 to your computer and use it in GitHub Desktop.
Save RCura/28250814ed96701f51bee9042f64c177 to your computer and use it in GitHub Desktop.
OSM download
myQuery <- "node['natural'='tree'](50.4353,4.8307,50.4788,4.9018);out;"
myJSONQuery <- curl::curl_escape(paste("[out:json];", myQuery, sep=""))
myURL <- paste("https://overpass-api.de/api/interpreter?data=", myJSONQuery, sep = "")
myURL
rawJson <- jsonlite::fromJSON(myURL)
json_data <- rawJson %>%
purrr::pluck("elements")
sf_data <- json_data %>%
st_as_sf(coords = c("lon", "lat"), crs = 4326)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment