Jupyternotebook

Display image from WMS (owslib)

[18]:
from owslib.wms import WebMapService
from IPython.display import Image

url = 'https://gpwmap.jaxa.jp/ows?'
layers = ['GCOM-C:LST250m_LST_Day']
bbox = [137.85, 35.15, 140.85, 36.85]
time = "2024-12-03T00:00:00Z/2024-12-03T23:59:59Z"
srs = "EPSG:4326"
format = "image/png"
size = [600,400]

wms = WebMapService(url)
img = wms.getmap( layers= layers, bbox=bbox, time=time, srs=srs, format=format, size=size)

Image(img.read())
[18]:
../../_images/tutorials_wms_jupyter_1_0.png

Display legend from WMS (owslib)

[75]:
from owslib.wms import WebMapService
from IPython.display import Image

url = 'https://gpwmap.jaxa.jp/ows?'
layer = 'GCOM-C:LST250m_LST_Day'
sld= 'LSTA-sld'

wms = WebMapService(url)

Image(url= wms[layer].styles[sld]['legend'])
[75]:

Overlay WMS image (folium)

[2]:
import folium

location = [36.0834, 140.0766]
url = 'https://gpwmap.jaxa.jp/ows?'
layers = ['GCOM-C:LST250m_LST_Day','GCOM-C:SST250m_SST_Day']
time = "2024-12-03T00:00:00Z/2024-12-03T23:59:59Z"
fmt = "image/png"

wms_map = folium.Map(location=location, zoom_start=9)

for layer in layers:
    folium.raster_layers.WmsTileLayer(url = url,
                                    layers = layer,
                                    time = time,
                                    fmt=fmt,
                                    name = layer,
                                    transparent = True,
                                    control = True,
                                    overlay = True,
                                    show = True
                                    ).add_to(wms_map)
folium.LayerControl().add_to(wms_map)

wms_map
[2]:
Make this Notebook Trusted to load map: File -> Trust Notebook

references