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

again a poor soul not managing to serve the tiles on remote server #95

Closed
12rambau opened this issue Jun 7, 2022 · 7 comments
Closed
Labels
bug Something isn't working

Comments

@12rambau
Copy link
Contributor

12rambau commented Jun 7, 2022

I know that it's a known issue, I'm not here to says it doesn't work, but more to say I think I don't understand the wiring.

What I tried

As simple as it seems my objective wa to check if I can display the example image on a map:

from localtileserver import get_leaflet_tile_layer, examples
from ipyleaflet import Map, LayersControl

client = examples.get_landsat(client_host="sepal.io", debug=True)

style = {
  'bands': [
    {'band': 5, 'palette': '#f00'},
    {'band': 3, 'palette': '#0f0'},
    {'band': 2, 'palette': '#00f'},
  ]
}

l = get_leaflet_tile_layer(client, style=style, name="toto")

m = Map(center=client.center(), zoom=client.default_zoom)
m.add_layer(l)
m.add_control(LayersControl())
m

As many before me I have the tile of the basemap but I don't see the "toto" layer.

status

https://sepal.io/api/tiles/10/191/384.png?&filename=/home/prambaud/.local/lib/python3.8/site-packages/localtileserver/tileserver/data/landsat.tif&style=%7B%22bands%22%3A%20%5B%7B%22band%22%3A%205%2C%20%22palette%22%3A%20%22%23f00%22%7D%2C%20%7B%22band%22%3A%203%2C%20%22palette%22%3A%20%22%230f0%22%7D%2C%20%7B%22band%22%3A%202%2C%20%22palette%22%3A%20%22%2300f%22%7D%5D%7D&projection=EPSG:3857

image

I don't want to write down many information that would be useless so I prefer to ask
Do you have any idea why the tiles are not rendering ?
Is there extra information that could be of any use ?
Is there test from my side that I can performed ? (I tried to activate the debug mode but it didn't gave me lots of information)

technical report

--------------------------------------------------------------------------------
  Date: Tue Jun 07 13:07:22 2022 UTC

                     OS : Linux
                 CPU(s) : 2
                Machine : x86_64
           Architecture : 64bit
                    RAM : 1.9 GiB
            Environment : Jupyter

  Python 3.8.10 (default, Mar 15 2022, 12:22:08)  [GCC 9.4.0]

        localtileserver : 0.5.8
                  flask : 2.1.2
          flask_caching : 1.11.1
             flask_cors : 3.0.10
            flask_restx : 0.5.1
               requests : 2.27.1
               werkzeug : 2.1.1
                  click : 8.1.3
          server_thread : 0.1.0
                 scooby : 0.5.12
            large_image : 1.14.5
large_image_source_gdal : 1.14.5
             cachetools : 4.2.4
                    PIL : 9.1.0
                 psutil : 5.5.1
                  numpy : 1.22.3
             palettable : 3.3.0
                 pyproj : 3.3.1
             osgeo.gdal : 3.4.0
               gunicorn : 20.1.0
             ipyleaflet : 0.14.0
              traitlets : 5.1.1
                shapely : 1.8.1.post1
                 folium : 0.12.1.post1
             matplotlib : 3.5.2
--------------------------------------------------------------------------------
@12rambau 12rambau changed the title again a issue serving the tiles on remote server again a poor soul not managing to serve the tiles on remote server Jun 7, 2022
@banesullivan
Copy link
Owner

banesullivan commented Jun 7, 2022

@12rambau, thanks for giving localtileserver a try and working hard to understand exactly what's going awry here - I understand this is probably a bit frustrating and I'd like to help get this working for you.

Overall, it seems you have set it up to work in a remote Jupyter environment as you are getting 200 statuses on your tiles. The confusing thing is that you are seeing fully transparent tiles - a transparent tile is generated when tiles are requested outside the bounds of the raster. A few things could go wrong here....

As a first check, could you make sure this behaves the same with folium as well: https://python-visualization.github.io/folium/

from localtileserver import get_folium_tile_layer, examples
from folium import Map

client = examples.get_landsat(client_host="sepal.io", debug=True)

style = {
  'bands': [
    {'band': 5, 'palette': '#f00'},
    {'band': 3, 'palette': '#0f0'},
    {'band': 2, 'palette': '#00f'},
  ]
}

l = get_folium_tile_layer(client, style=style, )#name="toto")

m = Map(location=client.center(), zoom_start=client.default_zoom)
m.add_child(l)
m

This will rule out any issues with the ipyleafelt BoundTileLayer that I provide in localtileserver:

class BoundTileLayer(TileLayer):
# https://github.com/jupyter-widgets/ipyleaflet/issues/888
# https://github.com/ipython/traitlets/issues/626#issuecomment-699957829
bounds = Union((Tuple(),), default_value=None, allow_none=True).tag(sync=True, o=True)

@12rambau
Copy link
Contributor Author

12rambau commented Jun 8, 2022

Thank you for your prompt answer. Until now I was using xarray_leaflet but recently geemap from @giswqs started using your lib for the same operation.

So I think I went a bit to fast looking at the payload. The images are not transparent, they are white in the preview (but as I'm not seeing them in the maps I assumed they were transparent). I unzoom to the maximum to check it wasn't a projection issue but they are nowere.

I tried the Folium implementation and the result is slightly different. There I get a 301 error.

@giswqs
Copy link
Contributor

giswqs commented Jun 8, 2022

@12rambau xarray-leaflet is no longer being actively developed and it never works on Windows, so I decided to switch to locatileserver. If you want to stick with xarray-leaflet, you can still use the add_raster_legacy() function.

https://geemap.org/geemap/#geemap.geemap.Map.add_raster_legacy

@12rambau
Copy link
Contributor Author

12rambau commented Jun 8, 2022

I'm only running things on a linux environment so that was not an issue (I have a pending issue for way to long on xarray_leaflet as well 😄 ). I saw the add_raster_legacy in the latest release (which is super convenient) but I would prefer to follow-up with new cool thing like this for my own mapping sytem.

@banesullivan
Copy link
Owner

@12rambau, were you able to resolve this issue? I'd be happy to help you debug this if you're still having trouble

@12rambau
Copy link
Contributor Author

nope I'm still a bit lost. Didn't have any idea but if you want me to check other stuff I'll be happy to give it a try

@12rambau
Copy link
Contributor Author

thanks a lot for your help @banesullivan I think I finally managed to find the server prefix needed to make it work. I simply use the one found in os.environ["SUDO_COMMAND"]:

import os 

os.environ["LOCALTILESERVER_CLIENT_PREFIX"] = "/api/sandbox/jupyter/proxy/{port}"

from localtileserver import get_folium_tile_layer, examples
from folium import Map

client = examples.get_landsat(client_host="sepal.io", debug=False)

style = {
  'bands': [
    {'band': 5, 'palette': '#f00'},
    {'band': 3, 'palette': '#0f0'},
    {'band': 2, 'palette': '#00f'},
  ]
}

l = get_folium_tile_layer(client, style=style)

m = Map(location=client.center(), zoom_start=client.default_zoom)
m.add_child(l)
m

Capture d’écran 2022-07-24 à 19 11 39

I'll close this one when I'll manage the full integration in our lib but that's a big step forward. I'll keep an eye on #101 as it sounds very promising.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants