Mapping with Leaflet
Clash Royale CLAN TAG#URR8PPP
Mapping with Leaflet
I am new to shiny and trying to do some mapping with leaflet.I already have the map layers though in qgs format.How can I use these qgis layers and make custom tiles(layers) for interactive mapping? Guidance on converting the qgis layers into leaflet mapping format would be appreciated.
Here is an image of the layers in QGIS:
Map Layers in QGIS
1 Answer
1
You can add layers by using e.g. addWMSTiles
. Here's a workable example below which add QGIS layer to interactive leaflet
Shiny app.
addWMSTiles
leaflet
library(shiny)
library(leaflet)
library(leaflet.extras)
ui <- fluidPage(
leafletOutput("mymap")
)
server <- function(input, output, session)
output$mymap <- renderLeaflet(
leaflet(
options = leafletOptions(
center = c(-33.95293, 20.82824),
zoom = 14,
minZoom = 5,
maxZoom = 18,
maxBounds = list(
c(-33.91444, 20.75351),
c(-33.98731, 20.90626)
)
)
) %>%
addWMSTiles(
baseUrl = paste0(
"http://maps.kartoza.com/web/?",
"map=/web/Boosmansbos/Boosmansbos.qgs"
),
layers = "Boosmansbos",
options = WMSTileOptions(format = "image/png", transparent = TRUE),
attribution = paste0(
"(c)<a href= "http://kartoza.com">Kartoza.com</a> and ",
"<a href= "http://www.ngi.gov.za/">SA-NGI</a>"
)
) %>%
addWMSLegend(
uri = paste0(
"http://maps.kartoza.com/web/?",
"map=/web/Boosmansbos/Boosmansbos.qgs&&SERVICE=WMS&VERSION=1.3.0",
"&SLD_VERSION=1.1.0&REQUEST=GetLegendGraphic&FORMAT=image/jpeg&LAYER=Boosmansbos&STYLE="
)
)
)
shinyApp(ui, server)
I was able to extract the layers from the qgis and combine with my csv data file.Thanks for the answer.
– user3649265
Aug 14 at 14:24
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Please read the info about how to ask a good question and how to give a reproducible example. This will make it much easier for others to help you.
– zx8754
Aug 8 at 14:19