Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use WMS in R?

Tags:

r

geospatial

wms

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?

like image 669
and-bri Avatar asked Oct 02 '16 09:10

and-bri


People also ask

How do I retrieve data from WMS?

WMS data extract files can be found under the /xfer/wms/reports file exchange directory and can be downloaded using an open-source SFTP client.


1 Answers

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.

like image 188
Hack-R Avatar answered Oct 20 '22 07:10

Hack-R