Created
January 24, 2023 22:36
-
-
Save steph-ben/2ca96ef5242f120265a3e3cbe69c18ed to your computer and use it in GitHub Desktop.
Expose dataset as WMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fsspec | |
import xarray as xr | |
import xpublish | |
from xpublish.routers import base_router, zarr_router | |
from xpublish_wms import cf_wms_router | |
fp = "arpege.json" | |
fs = fsspec.filesystem("reference", fo=str(fp)) | |
m = fs.get_mapper("") | |
ds = xr.open_dataset(m, engine="zarr", backend_kwargs=dict(consolidated=False), | |
chunks={'valid_time': 1}, drop_variables='orderedSequenceData') | |
rest = xpublish.Rest( | |
ds, | |
routers=[ | |
(base_router, {"tags": ["info"]}), | |
(cf_wms_router, {"tags": ["wms"], "prefix": "/wms"}), | |
(zarr_router, {"tags": ["zarr"], "prefix": "/zarr"}), | |
], | |
) | |
if __name__ == "__main__": | |
""" | |
Use online to check https://wms-viewer-online.appspot.com/indexmap.html | |
""" | |
rest.serve(workers=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment