addWMSTiles in shiny app with leaflet

439 views
Skip to first unread message

John froeschke

unread,
Jan 25, 2017, 2:23:40 PM1/25/17
to Shiny - Web Framework for R
I'm building a shiny app and I would like to use a NOAA nautical chart https://www.nauticalcharts.noaa.gov/csdl/seamlessraster.html as a basemap.  However, using the addWMSTiles() function has not been successful to date:  

This example from Rstudio works: 

library(leaflet)

leaflet() %>% addTiles() %>% setView(-93.65, 42.0285, zoom = 4) %>%
  addWMSTiles(
    layers = "nexrad-n0r-900913",
    options = WMSTileOptions(format = "image/png", transparent = TRUE),
    attribution = "Weather data © 2012 IEM Nexrad"
  )


The code below that I would like to use does not work:
leaflet() %>% addTiles() %>% 
 setView(-93.65, 28.0285, zoom = 4) %>%addWMSTiles(
  layers = 'NOAA_RNC',
  options = WMSTileOptions(format = "image/tiff", transparent = TRUE),
  attribution = "test") 

Any tips greatly appreciated.  

 session_info()
Session info ------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.3 (2015-12-10)
 system   x86_64, mingw32             
 ui       RStudio (1.0.136)           
 language (EN)                        
 collate  English_United States.1252  
 tz       America/New_York            
 date     2017-01-25                  

Packages ----------------------------------------------------------------------------------------------
 package     * version    date       source                            
 crosstalk     1.0.1      2017-01-25 Github (rstudio/crosstalk@6a36da1)
 devtools    * 1.12.0     2016-06-24 CRAN (R 3.2.5)                    
 digest        0.6.11     2017-01-03 CRAN (R 3.2.5)                    
 htmltools     0.3.5      2016-03-21 CRAN (R 3.2.3)                    
 htmlwidgets   0.8        2016-11-09 CRAN (R 3.2.5)                    
 httpuv        1.3.3      2017-01-25 Github (rstudio/httpuv@bf8ef78)   
 jsonlite      1.2        2016-12-31 CRAN (R 3.2.5)                    
 leaflet     * 1.0.2.9010 2017-01-25 Github (rstudio/leaflet@cbb3495)  
 magrittr      1.5        2014-11-22 CRAN (R 3.2.0)                    
 memoise       1.0.0      2016-01-29 CRAN (R 3.2.5)                    
 mime          0.5        2016-07-07 CRAN (R 3.2.5)                    
 R6            2.2.0      2016-10-05 CRAN (R 3.2.5)                    
 Rcpp          0.12.9     2017-01-14 CRAN (R 3.2.5)                    
 shiny         1.0.0      2017-01-12 CRAN (R 3.2.5)                    
 withr         1.0.2      2016-06-20 CRAN (R 3.2.5)                    
 xtable        1.8-2      2016-02-05 CRAN (R 3.2.5)                    
 yaml          2.1.14     2016-11-12 CRAN (R 3.2.5)  



heathe...@noaa.gov

unread,
Mar 27, 2017, 6:09:12 PM3/27/17
to Shiny - Web Framework for R
Hi John,

The code below is working for me.

Cheers,
Heather

target_ext$lon<-(-119.417931)
target_ext$lat<-40.078259
target_ext$zoom<-5


 #for some reason, piping %>% wasn't working quite right here, so doing them one at a time
      lmap <- leaflet()
      lmap <- addTiles(lmap)
      lmap <- setView(lmap, target_ext$lon, target_ext$lat, zoom=target_ext$zoom)
      lmap <- addWMSTiles(lmap,"https://seamlessrnc.nauticalcharts.noaa.gov/arcgis/services/RNC/NOAA_RNC/ImageServer/WMSServer",layers = 'NOAA_RNC',options = WMSTileOptions(format = "image/png", transparent = TRUE),
                          attribution = "")
      lmap
Reply all
Reply to author
Forward
0 new messages