SciTools / cartopy

Cartopy - a cartographic python library with matplotlib support
https://scitools.org.uk/cartopy/docs/latest
BSD 3-Clause "New" or "Revised" License
1.41k stars 359 forks source link

Unable to add WMS layer (Requested horizontal resolution exceeds...) #2034

Open guidocioni opened 2 years ago

guidocioni commented 2 years ago

Description

I'm trying to add a WMS layer from this source https://mappe.protezionecivile.gov.it/en/risks-maps/radar-map. I've successfully integrated it in the past into a Dash web application, so I know it is working, but somehow I cannot correctly format the request for Cartopy

Code to reproduce

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

fig = plt.figure(figsize=(20, 20))
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())

ax.set_extent([6, 19, 36, 47], ccrs.PlateCarree())
ax.add_wms("https://radar-geowebcache.protezionecivile.it/service/wms",
           ['radar:vmi'],
           wms_kwargs={'tiled':True, 'transparent':True,
                                     'version':'1.1.1', 'service':'WMS', 'request':'GetMap'})

I tried removing the kwargs but I still get the same error

Here is an example of a succesfull request link

https://radar-geowebcache.protezionecivile.it/service/wms?service=WMS&request=GetMap&tiled=true&time=2022-04-10T13:25:00.000Z&service=WMS&request=GetMap&layers=radar%3Avmi&styles=&format=image%2Fpng&transparent=true&version=1.1.1&width=256&height=256&srs=EPSG%3A3857&bbox=313086.06785608194,5009377.085697314,626172.1357121639,5322463.153553395

Traceback

[ServiceException: <html>
<head>
<title>GWC Error</title>
<link rel="stylesheet" href="../rest/web/gwc.css" type="text/css"/>
</head>
<body>
<div id="pageHeader"><a id="logo" href="../"><img src="../rest/web/geowebcache_logo.png"/></a></div>
<h4>400: Requested horizontal resolution: 0.05078125 , best match: 0.0439453125 exceeds 10% threshold. Perhaps the client is configured  with an incorrect set of scales (resolutions),  or the DPI setting is off compared to the one in GWC ?</h4></body></html>
]()<Figure size 1440x1440 with 1 Axes>
Full environment definition ### Operating system MacOS ### Cartopy version 0.20.2
dopplershift commented 2 years ago

It looks like the requested resolution is too coarse, but I have no idea where that would be coming from. No idea if there's something else you can pass in wms_kwargs, or within that the getmap_extra_kwargs key.