2017-01-30 50 views
0

我有這樣的WMS層:R:WMS地圖顯示不出來

http://apps.ecmwf.int/wms/?token=public&version=1.3.0&request=GetMap&layers=composition_bbaod550

我想將它添加到單張地圖,但它沒有顯示出來。 這是我的代碼:

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

leaflet() %>% addTiles() %>% setView(0, 50, zoom = 1) %>% 
    addWMSTiles("http://apps.ecmwf.int/wms/?token=public&version=1.3.0&request=GetMap", 
    layers = "composition_bbaod550", 
    options = WMSTileOptions(format = "image/png", transparent = TRUE)) 

我在做什麼錯?

編輯#1:

這裏是網絡請求的樣子從開發者控制檯

enter image description here

編輯#2:

這裏是我的代碼IvanSanchez的建議。正如你所看到的所提出的方法並沒有解決問題

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

leaflet() %>% addTiles() %>% setView(0, 50, zoom = 1) %>% 
    addWMSTiles("http://apps.ecmwf.int/wms/", 
    layers = "composition_bbaod550", 
    options = WMSTileOptions(token = "public", 
          srs = "EPSG:4326", 
          format = "image/png", 
          transparent = TRUE)) 
+0

我不一定需要使用傳單。它可以是一個靜態陰謀,因爲我只需要將它繪製在背景地圖上。 – Claudia

+0

你正在Rstudio預覽窗口中查看地圖嗎? –

+0

是的,我正在RStudio預覽窗口中查看地圖 – Claudia

回答

0

如果我們向WMS服務發出GetCapabilities請求,我們可以看到最高支持的WMS版本是1.1.1。所以你的GetMap請求版本= 1.3.0的WMS服務可能會出錯。

http://apps.ecmwf.int/wms/?token=public&service=WMS&request=GetCapabilities&

當我看着響應它似乎有一些錯誤,確實,當我在我的XML編輯檢查,有很多錯誤(這麼多,日誌是更大允許在這個答案的字數限制)。

WMS配置錯誤:

System ID: http://apps.ecmwf.int/wms/?token=public&service=WMS&request=GetCapabilities 
Main validation file: http://apps.ecmwf.int/wms/?token=public&service=WMS&request=GetCapabilities 
Schema: http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd 
Engine name: Xerces 
Severity: error 
Description: Attribute "xlink:execution" is not allowed to appear in element "OnlineResource". 
Start location: 44:17 
End location: 44:54 

System ID: http://apps.ecmwf.int/wms/?token=public&service=WMS&request=GetCapabilities 
Main validation file: http://apps.ecmwf.int/wms/?token=public&service=WMS&request=GetCapabilities 
Schema: http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd 
Engine name: Xerces 
Severity: error 
Description: Unexpected element "SRS". The content of the parent element type must match "(Name?,Title,Abstract?,KeywordList?,SRS*,LatLonBoundingBox?,BoundingBox*,Dimension*,Extent*,Attribution?,AuthorityURL*,Identifier*,MetadataURL*,DataURL*,FeatureListURL*,Style*,ScaleHint?,Layer*)". 
Start location: 97:8 
End location: 97:11 

System ID: http://apps.ecmwf.int/wms/?token=public&service=WMS&request=GetCapabilities 
Main validation file: http://apps.ecmwf.int/wms/?token=public&service=WMS&request=GetCapabilities 
Schema: http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd 
Engine name: Xerces 
Severity: error 
Description: Unexpected element "SRS". The content of the parent element type must match "(Name?,Title,Abstract?,KeywordList?,SRS*,LatLonBoundingBox?,BoundingBox*,Dimension*,Extent*,Attribution?,AuthorityURL*,Identifier*,MetadataURL*,DataURL*,FeatureListURL*,Style*,ScaleHint?,Layer*)". 
Start location: 122:10 
End location: 122:13 

System ID: http://apps.ecmwf.int/wms/?token=public&service=WMS&request=GetCapabilities 
Main validation file: http://apps.ecmwf.int/wms/?token=public&service=WMS&request=GetCapabilities 
Schema: http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd 
Engine name: Xerces 
Severity: error 
Description: Attribute "multipleValues" is not allowed to appear in element "Extent". 
Start location: 137:60 
End location: 137:78 

System ID: http://apps.ecmwf.int/wms/?token=public&service=WMS&request=GetCapabilities 
Main validation file: http://apps.ecmwf.int/wms/?token=public&service=WMS&request=GetCapabilities 
Schema: http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd 
Engine name: Xerces 
Severity: error 
Description: Unexpected element "SRS". The content of the parent element type must match "(Name?,Title,Abstract?,KeywordList?,SRS*,LatLonBoundingBox?,BoundingBox*,Dimension*,Extent*,Attribution?,AuthorityURL*,Identifier*,MetadataURL*,DataURL*,FeatureListURL*,Style*,ScaleHint?,Layer*)". 
Start location: 273:10 
End location: 273:13 

System ID: http://apps.ecmwf.int/wms/?token=public&service=WMS&request=GetCapabilities 
Main validation file: http://apps.ecmwf.int/wms/?token=public&service=WMS&request=GetCapabilities 
Schema: http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd 
Engine name: Xerces 
Severity: error 
Description: Attribute "multipleValues" is not allowed to appear in element "Extent". 
Start location: 288:60 
End location: 288:78 

System ID: http://apps.ecmwf.int/wms/?token=public&service=WMS&request=GetCapabilities 
Main validation file: http://apps.ecmwf.int/wms/?token=public&service=WMS&request=GetCapabilities 
Schema: http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd 
Engine name: Xerces 
Severity: error 
Description: Unexpected element "SRS". The content of the parent element type must match "(Name?,Title,Abstract?,KeywordList?,SRS*,LatLonBoundingBox?,BoundingBox*,Dimension*,Extent*,Attribution?,AuthorityURL*,Identifier*,MetadataURL*,DataURL*,FeatureListURL*,Style*,ScaleHint?,Layer*)". 
Start location: 393:10 
End location: 393:13 

...

的SRS/LatLonBoundingBox/BoundingBox的部分應類似於下面(結構,而不是內容):

<SRS>CRS:84</SRS> 
<SRS>EPSG:27700</SRS> 
<SRS>EPSG:3034</SRS> 
<SRS>EPSG:3413</SRS> 
<SRS>EPSG:3857</SRS> 
<SRS>EPSG:4258</SRS> 
<SRS>EPSG:4326</SRS> 
<SRS>EPSG:900913</SRS> 
<LatLonBoundingBox minx="-10.8018" miny="49.5889" maxx="3.92104" maxy="61.1359" /> 
<BoundingBox SRS="CRS:84" 
      minx="-10.8018" miny="49.5889" maxx="3.92104" maxy="61.1359" /> 
<BoundingBox SRS="EPSG:27700" 
      minx="-235677" miny="-34616" maxx="827937" maxy="1.28234e+006" /> 
<BoundingBox SRS="EPSG:3034" 
      minx="2.5664e+006" miny="2.55843e+006" maxx="3.67848e+006" maxy="3.94271e+006" /> 
<BoundingBox SRS="EPSG:3413" 
      minx="1.79406e+006" miny="-3.77262e+006" maxx="3.43831e+006" maxy="-2.09742e+006" /> 
<BoundingBox SRS="EPSG:3857" 
      minx="-1.20245e+006" miny="6.37538e+006" maxx="436488" maxy="8.6571e+006" /> 
<BoundingBox SRS="EPSG:4258" 
      minx="-10.8018" miny="49.5889" maxx="3.92104" maxy="61.1359" /> 
<BoundingBox SRS="EPSG:4326" 
      minx="-10.8018" miny="49.5889" maxx="3.92104" maxy="61.1359" /> 
<BoundingBox SRS="EPSG:900913" 
      minx="-10.8018" miny="49.5889" maxx="3.92104" maxy="61.1359" /> 

所以這個服務肯定配置不正確,這可能是你遇到任何問題的根本原因。

+0

非常感謝深入挖掘,我已經讓服務的維護人員知道。它現在有效! – Claudia

0

包括在基地version也不request參數WMS網址。這些由Leaflet內部添加。小冊子期望基地 WMS URL,如http://leafletjs.com/examples/wms/wms.html中所述。

所以不是

addWMSTiles("http://apps.ecmwf.int/wms/?token=public&version=1.3.0&request=GetMap", 

addWMSTiles("http://apps.ecmwf.int/wms/?token=public&", 

此外,從Leaflet WMS tutorial報價:

L.TileLayer.WMS有額外的選項,可以在Leaflet’s API documentation找到。在那裏沒有描述的任何選項將傳遞給getImage URL中的WMS服務器。

所以你實際上可以做

addWMSTiles("http://apps.ecmwf.int/wms/", 
    layers = "composition_bbaod550", 
    options = WMSTileOptions(token = "public", format = "image/png", transparent = TRUE)) 

如果失敗,你的瀏覽器(按F12)使用開發者控制檯,看到了網絡請求。對WMS的要求如何?


編輯:

調試的一點點後,似乎WMS服務器與響應:

<!DOCTYPE ServiceExceptionReport SYSTEM "/static/frontend/contrib/exception_1_1_1.dtd"> 

<ServiceExceptionReport version="1.1.1"> 
<ServiceException code='InvalidSRS'><![CDATA[ 
Unsupported projection 'EPSG:3857' 
]]> 

</ServiceException> 
</ServiceExceptionReport> 

這意味着WMS服務器不能夠輸出圖像中的哪適合Leaflet的默認地圖投影。

如果要使用此WMS服務器,您必須從GetCapabilities文檔中檢查支持的地圖投影列表,並使用Proj4Leaflet使地圖使用與默認值不同的投影。

務必閱讀:

對不起,沒有簡單的答案;你將不得不做一些工作並瞭解預測。

+0

感謝您的回答,但它對我無效。你的情況有效嗎?我編輯了我的問題,添加了我從開發者控制檯看到的網絡請求的屏幕截圖。 – Claudia

+0

我實際上對投影有所瞭解,該圖層位於緯度/經度(EPSG:4326,由傳單支持)。我試圖添加到選項,但它仍然無法正常工作。 – Claudia

+0

IvanSanchez,我不認爲這是回答我的問題,你的一些建議似乎有誤導性(proj4Leaflet.R已過時)。對不起,但我會冷靜下來! – Claudia