Can't add WMS layer to R Leaflet

24 views Asked by At

I want to make a leaflet map in R with this wms servic : https://data.geopf.fr/wms-r/wms?VERSION=1.3.0 It works well in QGIS but not with addWMSTiles.

library(leaflet)

layer="ADMINEXPRESS-COG-CARTO.LATEST"
url="https://data.geopf.fr/wms-r/wms?VERSION=1.3.0"

leaflet() %>% 
    setView(lng=3.18766,lat = 50.46302,zoom = 12) %>%
    addWMSTiles(
      baseUrl = url,
      layers = layer,
      group = "Limites administratives",
      options = WMSTileOptions(format = "image/png", transparent = TRUE,opacity=0.9,crs = 4326),
      attribution = "IGN"
    ) 

I try leaflet.extras2 pakcage, i try to put the number of the layer like on this post but it doesnt work at all. I try to change base url... I look trough informations in qgis with no sucess.

1

There are 1 answers

1
Romain On BEST ANSWER

I found the answer. I have to specify the version of the service in WMSTileOptions, which is weird because it's the same version as the older service...

library(leaflet)

layer="ADMINEXPRESS-COG-CARTO.LATEST"
url="https://data.geopf.fr/wms-r/wms?VERSION=1.3.0"

leaflet() %>% 
    setView(lng=3.18766,lat = 50.46302,zoom = 12) %>%
    addWMSTiles(
      baseUrl = url,
      layers = layer,
      group = "Limites administratives",
      options = WMSTileOptions(
          format = "image/png",
          transparent = TRUE,
          opacity=0.9,
          crs = 4326,
          version="1.3.0"
        ),
      attribution = "IGN"
    )