Closed banesullivan closed 1 year ago
Regarding ipyleaflet, see https://gist.github.com/manthey/a66f69ae84dc59bbd54c2fbbb1c8844f. If I remember rightly, the only true weirdness was that ipyleaflet doesn't fully apply projection parameters, so the coordinates are Y, X rather than the image user's expected X, Y.
_repr_html_
is a fantastic way to add an interactive representation style for objects in Jupyuter and we could easily expose a slippy-maps style viewer that fetches tiles from a large-image source.For example, I implemented this in
localtileserver
: https://localtileserver.banesullivan.com/user-guide/index.html#user-guideI'd like to wrap up the rasterio source and consolidate a new "GeoBaseTileSource", then think about implementing this as:
_repr_html_
on the baseTileSource
class that shows an slippy maps style image viewer (non-geospatially referenced)_repr_html_
on the base "GeoBaseTileSource" that has a geospatial referenceImplementation
We need to launch a webserver to host the endpoints for our JS-based viewer to fetch tiles from. Launching the server isn't too bad and as I've shared in plenty of places, we can do this easily with server-thread and a simple wsgi/asgi app.
Here is a minimal, yet fairly robust example:
Complications
An issue arises from gaining access to that webserver when running on managed, deployed environments (think MyBinder, university JupyterLab deployments, Sagemaker, etc.), we'll likely need to rely on
jupyter-server-proxy
to proxy the port so that the user's web browser can access this. Thing is, it has to be configured slightly differently in just about every managed environment -- a maintenance and support burden we're facing on PyVista with its webserver-based Jupyter viewer.Though, a good chunk of the implementation to support most platforms in a standard way can be taken from
localtileserver
: https://github.com/banesullivan/localtileserver/blob/main/localtileserver/configure.pyWhich viewer do we use?
We could custom bundle a viewer based on GeoJS, CesiumJS, LeafletJS, etc and this wouldn't require any additional dependencies. However, this would be somewhat of "oh neat,... but I can't do anything with that" situation. I think it would behoove us to add an
extra_requires
section for Jupyter that would leverageipyleaflet
for creating these viewers in Jupyter. This would enable users to add annotations, add additional tile sources, and customize to their heart's desire.Using
ipyleaflet
will require nailing down the non-geospatial case as it's still a bit weird: https://localtileserver.banesullivan.com/user-guide/non-geo.html