1

I am attempting to display an interactive map of past rainfall using leaflet in R. The best available data I was pointed to was located here: https://mapservices.weather.noaa.gov/raster/rest/services/obs/rfc_qpe/MapServer

The example layer I am trying to display is rainfall accumulation from the past 24-hours, indicated as layer 28. When trying to display with leaflet, the data does not seem to show, and no errors are given:

library(leaflet)

url = "https://mapservices.weather.noaa.gov/raster/rest/services/obs/rfc_qpe/MapServer"

leaflet() %>%
  addTiles() %>%
  addWMSTiles(url,
              layers="0",
              layerId = '28',
              options = WMSTileOptions(format = "image/png",
                                       transparent = TRUE,
                                       opacity=.7),
              group = "24-Hr Accumulation") %>%
  addLayersControl(overlayGroups = "24-Hr Accumulation")

Created on 2023-05-17 with reprex v2.0.2

Presumably, my issue is with the layers = "0" and layerId = "28" arguments.

5
  • 1
    WMS URL is: https://mapservices.weather.noaa.gov/raster/services/obs/rfc_qpe/MapServer/WMSServer?
    – nmtoken
    Commented May 17, 2023 at 14:26
  • 1
    There isn't a layer "0"
    – nmtoken
    Commented May 17, 2023 at 14:35
  • @nmtoken Okay. Layer 28 is the one I'm looking for, so I'm unsure which argument to give the value of "28". Commented May 17, 2023 at 14:41
  • 1
    Layers is a WMS parameter so assume it would be layers="28", layerId is not a WMS parameter, but I don't know R, so not sure if it is translated to a valid WMS parameter when the request is generated. A valid WMS GetMap request for layer 28 would be: mapservices.weather.noaa.gov:443/raster/services/obs/rfc_qpe/…
    – nmtoken
    Commented May 17, 2023 at 14:54
  • @nmtoken Oh I see the issue, layer 28 provides some sort of boundary rather than a raster image that I was looking for. I should be using layer 26. Thank you for your help in finding this issue and fixing the URL! Commented May 17, 2023 at 15:07

1 Answer 1

3

This worked for me in R Studio:

library(leaflet)

url = "https://mapservices.weather.noaa.gov/raster/services/obs/rfc_qpe/MapServer/WMSServer?"
leaflet() %>%
    addTiles() %>%
    addWMSTiles(url,
    layers = "26,28", 
    options =  WMSTileOptions(format = "image/png",
        transparent = TRUE)
)

Gives: Two layers from WMS using Leaflet package in R

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.