1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
# TimestampedWmsTileLayers
Add a time dimension to a WMS tile layer.
### Exploring the WMS with OWSLib
```{code-cell} ipython3
from owslib.wms import WebMapService
url = "https://pae-paha.pacioos.hawaii.edu/thredds/wms/dhw_5km?service=WMS"
web_map_services = WebMapService(url)
print("\n".join(web_map_services.contents.keys()))
```
### Layer metadata
```{code-cell} ipython3
layer = "CRW_SST"
wms = web_map_services.contents[layer]
name = wms.title
lon = (wms.boundingBox[0] + wms.boundingBox[2]) / 2.0
lat = (wms.boundingBox[1] + wms.boundingBox[3]) / 2.0
center = lat, lon
time_interval = "{0}/{1}".format(
wms.timepositions[0].strip(), wms.timepositions[-1].strip()
)
style = "boxfill/sst_36"
if style not in wms.styles:
style = None
```
### Map with WmsTileLayer and TimestampedWmsTileLayers
```{code-cell} ipython3
import folium
import folium.plugins
m = folium.Map(location=[-40, -50], zoom_start=5)
wms_tile_layer = folium.WmsTileLayer(
url=url,
name=name,
styles=style,
fmt="image/png",
transparent=True,
layers=layer,
overlay=True,
COLORSCALERANGE="1.2,28",
).add_to(m)
folium.plugins.TimestampedWmsTileLayers(
wms_tile_layer,
period="PT1H",
time_interval=time_interval,
).add_to(m)
folium.LayerControl().add_to(m)
m
```
|