如何从特定时间/日期检索WMS图像

时间:2017-01-17 20:03:10

标签: r leaflet wms

我正试图从装载在R中的传单中的KNMI获取降水雷达数据。数据位于:http://adaguc.knmi.nl/contents/webservices/WebServices_RADNL_OPER_R___25PCPRR_L3.html

到目前为止,我已设法使用以下代码将当前雷达图像传送到传单图层:

# ARGV is an array of the arguments passed to the script.
ARGV[0..-3].each do |f| # enumerate the arguments of this script from the first to the last (-1) minus 2
  File.write(f,  # open the argument (= filename) for writing
    File.read(f) # open the argument (= filename) for reading
    .gsub(ARGV[-2],ARGV[-1])) # and replace all occurances of the beforelast with the last argument (string)
end

到目前为止一直很好......

但我真正想要的是从给定的时间戳获得雷达图像。该系列可以追溯到2009年(参见KNMI查看器中的示例:http://geoservices.knmi.nl/viewer2.0/?srs=EPSG%3A3857&bbox=-725.7203842048766,6500000,1220725.7203842048,7200000&service=http%3A%2F%2Fgeoservices.knmi.nl%2Fcgi-bin%2FRADNL_OPER_R___25PCPRR_L3.cgi%3F&layer=RADNL_OPER_R___25PCPRR_L3_COLOR%24image%2Fpng%24true%24default%241%240&selected=0&dims=time $ current& baselayers = streetmap $ world_line)。

在网络上,我找到了几个支持日期/时间的传单示例(如:http://apps.socib.es/Leaflet.TimeDimension/examples/example14.html),但不幸的是我缺乏将此示例转换为传单的R版本的技能。 / p>

可以这样做吗?例如,我可以从2017-01-07T04:00检索降水雷达图像吗?如果是的话:我会在哪里开始?

或者如果不能用传单做;还有其他建议吗?

1 个答案:

答案 0 :(得分:0)

这比预期的要容易; - )

我只需要在WMSTileOptions中添加一个TIME变量。

这有效:

require("leaflet")
require("dplyr")
 leaflet() %>% addTiles() %>% 
  addWMSTiles(
    "http://geoservices.knmi.nl/cgi-bin/RADNL_OPER_R___25PCPRR_L3.cgi",
    layers = "RADNL_OPER_R___25PCPRR_L3_COLOR",
    options = WMSTileOptions(format = "image/png", transparent = TRUE, TIME = "2017-01-07T04:00:00"),
    attribution = "KNMI neerslagradar"
  )