Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would it be feasible to provide a WMS route? #53

Closed
cwerner opened this issue Aug 28, 2020 · 15 comments
Closed

Would it be feasible to provide a WMS route? #53

cwerner opened this issue Aug 28, 2020 · 15 comments

Comments

@cwerner
Copy link

cwerner commented Aug 28, 2020

Hi

Recently stumbled upon this neat little library. I currently have the problem that I'm building a dashboard using streamlit and folium. On the folium map, I'd like to overlay a raster which can be achieved rather easy if this is hosted via WMS somewhere. Now, I'd like to avoid hosting this single file via something expensive as geoserver or a threads instance just for this single map.

Would it be feasible to implement a WMS access option in Xpublish? not sure about the boilerplate required for doing this... 🤷‍♂️

@jhamman
Copy link
Contributor

jhamman commented Aug 28, 2020

Yes! This should be perfectly feasible. You'll need to create a new custom router that exposes an WMS endpoint. I think for a simple WMS endpoint, it will probably be easiest to just write the GET/POST routes from scratch but you should certainly take a look at the existing implementations in OWSLib before getting started. Between @benbovy and I, we can help point you in the right direction for getting the xpublish router stuff working.

@cwerner
Copy link
Author

cwerner commented Aug 28, 2020

Great

Unfortunately with regard to the WMS protocol and internals I‘m merely a user and implementing this myself might be well over my head (but I’ll try to read up on it).
Would integrating something like skinnywms into Xpublish work? https://github.com/ecmwf/skinnywms

@benbovy
Copy link
Contributor

benbovy commented Sep 18, 2020

Would integrating something like skinnywms into Xpublish work?

I think it would be be better if xpublish doesn't rely on 3rd party servers like skinnywms in order to keep the deployment easy. Thanks to FastAPI, It should be pretty straightforward to implement the WMS API endpoints in xpublish from scratch.

A good part of the work to support WMS is to properly handle plotting of the data and exporting it to a PNG/JPG image. This is something that we could delegate to a 3rd party library like Holoviews/Datashader as suggested in #50 (comment).

@iacopoff
Copy link

Hi @benbovy and @jhamman, I would like this feature available in xpublish so I thought I would start working on it. Actually, I am not an expert in WMS but I think I can manage! Surely a little bit of guidance is definitely welcome :).

@benbovy
Copy link
Contributor

benbovy commented Jun 14, 2021

Hi @iacopoff, I'm not an expert in WMS either, but it might be worth looking at those projects:

  • Titiler implements WMTS endpoints also using fastAPI, although using different data sources than xarray.Dataset.

  • Xarray-leaflet dynamically generates and serves images from xarray objects, although it targets another front-end / protocol.

@iacopoff
Copy link

Hi @benbovy, great, thanks for the suggestions. I have just forked the repo. I am going to start working on it from mid July, after holidays!

@iacopoff
Copy link

Hi @benbovy,
my understanding is that the key ingredients are:

  • WMTS interface (GetCapabilities, GetTile, and possibly GetFeatureInfo), as new custom router in xpublish
  • Functionality to generate tiles from xarray.Dataset (either static or dynamically) stored as png images in a temporary folder, so that they can be requested by the web client

Does it sound correct? Are you suggesting to use Titiler for both somehow?

@benbovy
Copy link
Contributor

benbovy commented Jul 20, 2021

Hi @iacopoff, it sounds good to me. I had a look at Titiler a while ago, I'm not sure how easy / hard would it be to reuse it instead of re-implementing the same functionality here.

I guess we would need a custom subclass of rio_tiler.BaseReader subclass, which is used by Titiler router factory classes. However, rio_tiler.BaseReader is specific to rasterio and expects a dataset url as parameter, whereas in Xpublish we use a get_dataset fastapi dependency to directly access the xarray Dataset object being served. I'm not sure how this could be integrated together.

@iacopoff
Copy link

Hi @benbovy, I have started with something simpler: an XYZ service.
To create the tiles, I am using Datashader but I guess that I could alternatively use Pillow/PIL if needed.
The tricky bit is to get the dataset's coordinates into the correct WGS 84/Pseudo-Mercator projection, which seems to be the standard projection required by web map services.
thanks

@benbovy
Copy link
Contributor

benbovy commented Jul 20, 2021

An XYZ service would be a very nice addition too and I guess it could share many things with a WMTS regarding their implementation.

For the (re)projection, you may want to look at how Xarray-leaflet handles it. It think it's based on morecantile and rioxarray.

@iacopoff
Copy link

Hi @benbovy, I think I have now something working.
What is the best way for you to review/comment?
Shall I open a PR or you could just try the xyz_router from my forked xpublish repo? I have added server/client notebooks that show how to use the xyz service.
thanks!

@benbovy
Copy link
Contributor

benbovy commented Jul 26, 2021

Yes please open a PR!

@abkfenris
Copy link
Member

If folks are looking for WMS in Xpublish, @mpiannucci has created a plugin that will give you WMS routes without creating your own router.

@mpiannucci
Copy link
Contributor

If folks are looking for WMS in Xpublish, @mpiannucci has created a plugin that will give you WMS routes without creating your own router.

Very much a work in progress, but it shows how easy the flow is with plugins

@mpiannucci
Copy link
Contributor

mpiannucci commented Apr 7, 2023

I moved xpublish-wms to the xpublish-community org here!

@jhamman jhamman closed this as completed Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants