How to use WMS in R?
Asked Answered
W

1

10

I like to implement a special WMS-layer with leaflet() in R. But I have no success with the WMS-layer I like to use.

library("leaflet")
library("sp")

# this example from the tutorial works
leaflet() %>% addTiles() %>% setView(-93.65, 42.028, zoom = 4) %>%
  addWMSTiles(
    "http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi",
    layers = "nexrad-n0r",
    options = WMSTileOptions(format = "image/png", transparent = TRUE) 
)

# but for my implementation it don't work
leaflet() %>% addTiles() %>% setView(lat = 53.8, lng = 12.6, zoom = 8) %>% 
  addWMSTiles("http://www.umweltkarten.mv-regierung.de/script/mv_a3_wasserschutz_wms.php?", 
              layers = "t2_bib_p", 
              options = WMSTileOptions(format = "image/png")
)

I assume that there is a problem with the Coordinate Refernce System. Because the WMS-layer I like to use, have not a standard CRS. So I try to expermented with this WMSTileOptions():

crs=CRS("+init=epsg:5650")

The idea is to use WMS-Layers as background images for my vector data. The vector data come mainly from shape-files and GPS-data (text files). The purpose is to create maps which i can use in a report. If you know other possibles beside leaflet to use WMS in R there are also welcome?

Wie answered 2/10, 2016 at 9:7 Comment(4)
No idea where your conclusion comes from. Shape file, tableau data of coordinates are very common data type for most GIS APIs. And leaflet/MapBox is build based on OGC protocal, wms as its default component... Plus crs or customized projections are handled by your projection engine/application usually at data preparation stage or server side. That been said, there are multiple libraries provide that such as in MapBox which is build on leaflet and proj4js for standalone lib. Publish vector data as WMS is one the basic functions, and with a projection lib you should be able to do that easily.Barrator
I made my question more clear. The vector are not the problem...The librarys you mending I will check later.Wie
I don't speak German, but I was concerned that this message may indicate that the service is offline. Could you verify this for me? "ACHTUNG: Ab 04.10.2016 werden nur noch die Themendienste (WMS/WFS) gem. unten stehender Liste angeboten. Der "große" Dienst lung_wms_wms steht dann nicht mehr zur Verfügung. Die Themendienste enthalten alle freigegebenen Themen."Grimbal
jep...it could(!) mean that the WMS-Layer is not anymore available. The message say that there is a list at the bottom of this page where all the available WMS's are listed. But anyway...I right now checked the WMS address in the example up - and it work in qgis but not in R.Wie
G
1

I notice that if you investigate that base URL it says

msWMSDispatch(): WMS server error. Incomplete WMS request: VERSION parameter missing

and by researching the website I determined that the proper format is:

https://www.umweltkarten.mv-regierung.de/script/mv_a3_wasserschutz_wms.php?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0

which yields quite a lot of WMS data if you put it in your browser.

We can use "find" to see which layers are available to be queried. There are several, such as t3_ksg, t3_wsg, and lungwms, but it seems that t2_bib_p is not available for mv_a3_wasserschutz_wms.

Grimbal answered 9/10, 2016 at 22:37 Comment(1)
thx for the help... but even when I use your address and the layer you mentioned it don't work for me in R . Can you please post the code you use for use the WMS and apply the find() function.Wie

© 2022 - 2024 — McMap. All rights reserved.