xarray-contrib / xarray_leaflet

An xarray extension for tiled map plotting.
https://xarray-leaflet.readthedocs.io
MIT License
157 stars 21 forks source link

No data display #40

Closed 12rambau closed 2 years ago

12rambau commented 3 years ago

I know that this is the exact same title as #39 But as the OP now have a solution that cannot be used in my case I preferred to open a new one.

I'm working on a company environment so I have no opportunity to start from a "fresh" conda env and I'm force to better understand the libs we use. We were using the lib to display raster as in the geemap librairy and it was working very effectivelly.

As referred here, we recently lost the abbility to load anything on the map...

I checked my configuration over the one in setup.py

setup.py our environment
jupyter_server>=0.2.0 jupyter-server==1.4.1
rioxarray>=0.0.30 rioxarray==0.3.1
ipyleaflet>=0.13.1 ipyleaflet==0.13.3
pillow>=7 Pillow==8.1.1
ipyspin>=0.1.1 ipyspin==0.1.5
mercantile>=1 mercantile==1.1.6
affine>=2 affine==2.3.0
matplotlib>=3 matplotlib==3.3.4

It should work but instead the spinning wheel turns forever and nothing appears on the map.

I also check the javascript console and appart from warnings about the cartoDB basemap, nothing.

Would you think about anything that could prevent the loading of the generated tiles ? (I'm in particular thinking about authorization to read or write in specific folder but I don't knwo which one to verify)

davidbrochart commented 3 years ago

By default tiles are saved in tempfile.TemporaryDirectory(prefix='xarray_leaflet_'). On Linux this will translate to a path starting with /tmp/xarray_leaflet_. So you can e.g. ls -lrt /tmp and see if something has been written there. In the browser you could look at the network analyzer and see the status of the requests corresponding to the tiles.

12rambau commented 3 years ago

Well, I gave all I had but it's clearly beyond my skills ;-)

new intel

The tmp/xarray_leaflet_turlutut/ folder is never filled or created so I don't have any tiles to load. but the tmp can be written so normally no problem there.

I don't see any requests in the network analyser, I have the feeling that this step is never reached.

I want to mention that our env is in Python 3.6.9 and that my ipyleaflet version is limited to 0.13.3 by geemap. but I don't see any problem according to your setup.py.

I tried to display a lot of intermediate output to see where it was blocked but I can't get the output_debug to work properly. It writes the first print statement but as soon as we go to async def or functions called by the observe on "bounds" I see nothing.

Question:

url

The shape of the url to fetch the tiles (base_url) must look like the following right:

https://sepal.io/api/sandbox/jupyter 

Basically everything up to the first "jupyter"

That makes a final url of the form :

https://sepal.io/api/sandbox/jupyter/xarray_leaflet/tmp/xarray_leaflet_turlututu/{z}/{x}/{y}.png

If this is the case, I have to modify the base_url construction, I made a mistake for lab in my last PR.

fit_bounds functions

Then if I set fit_bounds to False, async_wait_for_bounds doesn't launch if I don't zoom right ?

giswqs commented 3 years ago

@12rambau You can update ipyleaflet to the latest version and geemap should work just fine. The reason I put ipyleaflet v0.13.3 is because ipyleaflet>0.13.3 pip installation does not work properly on Windows https://github.com/jupyter-widgets/ipyleaflet/issues/769. For conda installation, geemap should automatically install the latest ipyleaflet. https://github.com/conda-forge/geemap-feedstock/blob/master/recipe/meta.yaml

12rambau commented 3 years ago

@giswqs is it still working on your side in geemap ?

giswqs commented 3 years ago

I just tested the notebook example on my Linux machine with Python 3.8 and ipyleaflet 0.13.6. It works fine.

https://geemap.org/notebooks/25_load_rasters

https://user-images.githubusercontent.com/5016453/111326687-24026680-8643-11eb-9d45-465c1fcd7724.mp4

12rambau commented 3 years ago

ok so I welcome myself in the compatibility nightmare

I think I find a solution.

Good thing though is that now that I really dig in your code @davidbrochart, I better understand what you've done and better understand the power of async function. Thanks and congrats !

I will close this issue once everything is set on the prod env of the SEPAL website

bmcandr commented 3 years ago

It should work but instead the spinning wheel turns forever and nothing appears on the map.

Hi, I'm experiencing this issue as well on both Linux and Mac.

I do not encounter this issue in the Binder for this repo.

davidbrochart commented 3 years ago

Maybe you could have a look at the debug_output in the dynamic.ipynb notebook?

peterhob commented 3 years ago

42 helped solve this issue. I modified the code block

if self.url.endswith('/lab'):
    # we are in JupyterLab
    self.base_url = self.url[:-4]

to

if self.url.find('/lab/') != -1:
    # we are in JupyterLab
    i_lab=self.url.find('/lab/')
    self.base_url = self.url[:i_lab]
davidbrochart commented 2 years ago

See #45