Shiny App with OSM Data

I have a leaflet map that is powered by osmdata. I have tried to apply this in a shiny app. The app runs but the map does not appear.

library (sf)
x <-opq(bbox=c(-3.845215,51.041394,4.658203,58.642653),timeout = 25*1000)%>%
  add_osm_feature("plant:source","wind") %>%

ui <- fluidPage(
  headerPanel("Asset Header"),


                          map= leaflet()%>%addTiles()%>%addPolygons(data=x,
                          popup = paste("Name:",x$Project.Name,"<br/>"))

  output$myMap = renderLeaflet(map)
shinyApp(ui = ui, server = server)

Is there a reason the leaflet map does not appear?
Should I query osm everytime or should I save the data locally via *.rds?


Hi - I found the answer and solution to my issue from:

Shiny is already establishing a URL connection between a server (in this case your computer is being used as a server as the app is located there) and the browser, and you are allowed to create more direct connections within shiny, but OSMdata, sends a query to the Overpass Turbo service (the overpass turbo translate your query from a scripting language to a compact format, for the API to understand it) then the overpass turbo sends the translated query to the overpass API and the overpass API send the results back to us.

For our shiny app to work properly, we need to get rid of the intermediate step and do a direct query to the overpass API.

I hope others find this question useful


This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.