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

Cannot view tiles in remote Jupyter environment #66

Closed
MATRIX4284 opened this issue Feb 3, 2022 · 28 comments
Closed

Cannot view tiles in remote Jupyter environment #66

MATRIX4284 opened this issue Feb 3, 2022 · 28 comments

Comments

@MATRIX4284
Copy link

Raster layer map not displayed for TileClient with local files.

The raster layer comng from local file is not being displayed on map

@giswqs
Copy link
Contributor

giswqs commented Feb 3, 2022

You need to provide information about OS and env. Providing the sample dataset would be helpful.

import localtileserver
print(localtileserver.Report())

@banesullivan
Copy link
Owner

Screenshots and code would also be helpful

@MATRIX4284
Copy link
Author

MATRIX4284 commented Feb 3, 2022

import localtileserver
print(localtileserver.Report())
--------------------------------------------------------------------------------
  Date: Fri Feb 04 03:44:31 2022 IST

                     OS : Linux
                 CPU(s) : 32
                Machine : x86_64
           Architecture : 64bit
                    RAM : 125.9 GiB
            Environment : Jupyter
            File system : ext4

  Python 3.7.11 (default, Jul 27 2021, 14:32:16)  [GCC 7.5.0]

        localtileserver : 0.4.0
                  flask : 2.0.2
          flask_caching : 1.10.1
            flask_restx : 0.5.1
               requests : 2.27.1
               werkzeug : 2.0.2
                  click : 7.1.2
                 scooby : 0.5.11
            large_image : 1.10.0
large_image_source_gdal : 1.10.0
             cachetools : 4.2.4
                    PIL : 9.0.0
                 psutil : 5.8.0
                  numpy : 1.21.2
             palettable : 3.3.0
                 pyproj : 3.1.0
             osgeo.gdal : 3.3.1
             ipyleaflet : 0.14.0
              traitlets : 5.1.1
                shapely : 1.7.1
                 folium : 0.12.1.post1
             matplotlib : 3.5.0
--------------------------------------------------------------------------------

@MATRIX4284
Copy link
Author

MATRIX4284 commented Feb 3, 2022

from localtileserver import get_leaflet_tile_layer, TileClient
from ipyleaflet import Map

# First, create a tile server from local raster file
tile_client = TileClient('/DISK003/SPATIAL_ANALYTICS/landuse.tif')

# Create ipyleaflet tile layer from that server
t = get_leaflet_tile_layer(tile_client)

# Create ipyleaflet map, add tile layer, and display
m = Map(center=tile_client.center())
m.add_layer(t)
m

@MATRIX4284
Copy link
Author

the tile layer id not getting displayed in map

@banesullivan
Copy link
Owner

Would it be possible to share the landuse.tif file?

the tile layer id not getting displayed in map

I do not understand what you mean... could you include screenshots?

@MATRIX4284
Copy link
Author

landuse.tiff.zip
it is clearly getting plotted in QGIS

@MATRIX4284
Copy link
Author

attached the zip file of the tif as it was not allowing to attach tiff directly

@MATRIX4284
Copy link
Author

you can try to visualize the tif in QGIS as a reference

@banesullivan
Copy link
Owner

I am having no issues visualizing this raster with localtileserver. From what I can tell, there isn't anything wrong with the file and localtileserver handles it as well as any of the examples.

Here is the code I used:

from localtileserver import get_leaflet_tile_layer, TileClient
from ipyleaflet import Map

# First, create a tile server from local raster file
tile_client = TileClient('landuse.tiff')

# Create ipyleaflet tile layer from that server
t = get_leaflet_tile_layer(tile_client)

# Create ipyleaflet map, add tile layer, and display
m = Map(center=tile_client.center())
m.add_layer(t)
m

and a screenshot of Jupyter:

Screen Shot 2022-02-04 at 2 23 25 PM

further, the command-line utility has no issue showing this in CesiumJS:

localtileserver landuse.tiff

Screen Shot 2022-02-04 at 2 18 42 PM


@MATRIX4284, in order to help you further, I need you to specify exactly what is going wrong:

the tile layer id not getting displayed in map

I'm not sure what you mean by this.

Would you please included screenshots of what is happening and describe what you expect to happen?

@MATRIX4284
Copy link
Author

how come it is possible i am ruuning the same set of commands and i can see only the basemap but not any other layer

@banesullivan
Copy link
Owner

@MATRIX4284, I'm not sure. Are you seeing any errors? In the JavaScript console of your browser are you seeing any errors? in the network tab of the dev tools in your browser, are you seeing any 404s?

Is it possible you are running on a remote system where your web browser might not have access to the port on which localtileserver is serving the imagery?

@MATRIX4284
Copy link
Author

As you can see i can see basemap layer but not the layer in showing the land usage.I am not abe to comprehend the reason why it is not showing up in my machine despite similar code snippets used.

@MATRIX4284
Copy link
Author

is there any dependency on chrome version ??

@MATRIX4284
Copy link
Author

localtileserveroutout

@MATRIX4284
Copy link
Author

os:ubunyu 16.04
python:

@MATRIX4284, I'm not sure. Are you seeing any errors? In the JavaScript console of your browser are you seeing any errors? in the network tab of the dev tools in your browser, are you seeing any 404s?

Is it possible you are running on a remote system where your web browser might not have access to the port on which localtileserver is serving the imagery?

yes i am using remote system where my jupyter is running at port 15000 .I am connecting to jupyer by ip:port

@MATRIX4284
Copy link
Author

MATRIX4284 commented Feb 4, 2022

i just tested the docker with the volume the output is showing with
docker run -p 15003:8000 -v /DISK003/SPATIAL_ANALYTICS/:/data/ ghcr.io/banesullivan/localtileserver:latest

@MATRIX4284
Copy link
Author

MATRIX4284 commented Feb 4, 2022

but python module when installed on os is not showing up the stuff neither the tile layer is showing up in jupyter

@banesullivan
Copy link
Owner

banesullivan commented Feb 6, 2022

Aha. This is a duplicate of #29 which isn't fully solved. banesullivan/localtileserver-demo#1 also tracks this

Because you are running in a remote environment, you must set up your server to expose the port the on which localtileserver is serving the image tiles. localtileserver randomly chooses a port by default, so you will need to allocate a port and pass it to localtileserver. For example, use 8000:

tile_client = TileClient('landuse.tiff', port=8000)

I don't have a good solution to this use case (yet).

@banesullivan banesullivan changed the title Raster layer map not displayed for TileClient with local files Cannot view tiles in remote Jupyter environment Feb 6, 2022
@banesullivan
Copy link
Owner

banesullivan commented Feb 6, 2022

Release 0.4.1.dev0 provides an interface that allows for a solution to this and #29 and banesullivan/localtileserver-demo#1 using jupyter-server-proxy

This can get messy/complicated and I haven't documented (at all), but essentially localtileserver.TileClient now allows you to map the server's host and port to what your browser sees as the host (and port). To use this, specify port, client_port client_host, and client_prefix on init of TileClient. Or better yet, set the following environment variables where you are running Jupyter:

  • LOCALTILESERVER_PORT=5555
  • LOCALTILESERVER_CLIENT_PORT=8888
  • LOCALTILESERVER_CLIENT_HOST=127.0.0.0
  • LOCALTILESERVER_CLIENT_PREFIX=proxy/$LOCALTILESERVER_PORT

This effectively remaps the tile requests coming from ipyleaflet from localhost:5555 to 127.0.0.0:8888/proxy/5555 allowing your browser access

You can also use/see jupyter.Dockerfile:

cc @giswqs

I will follow up in banesullivan/localtileserver-demo#1 with a demo and soon release 0.4.1

@giswqs
Copy link
Contributor

giswqs commented Feb 6, 2022

@banesullivan You rock! This is exciting! Can't wait to try it out.

@giswqs
Copy link
Contributor

giswqs commented Feb 6, 2022

It seems the binder system username is jovyan. Can you set those env variables automatically when the system username is jovyan?

image

@banesullivan
Copy link
Owner

Yep! You should be able to set env variable no matter the user

@banesullivan
Copy link
Owner

banesullivan commented Feb 6, 2022

I just pushed 0.4.1 which removed LOCALTILESERVER_PORT and now requires you to set the following to work with jupyter-server-proxy:

  • LOCALTILESERVER_CLIENT_HOST=127.0.0.1 - The host on which you launch Jupyter
  • LOCALTILESERVER_CLIENT_PORT=8888 - The port on which you launch Jupyter
  • LOCALTILESERVER_CLIENT_PREFIX='proxy/{port}' - Same for everyone using jupyter-server-proxy

@MATRIX4284
Copy link
Author

I will test after setting the variables accordingly

@banesullivan
Copy link
Owner

This was further improved in #67 such that only setting:

LOCALTILESERVER_CLIENT_PREFIX='proxy/{port}' should be sufficient for you, @MATRIX4284

I will release 0.4.2 shortly

@banesullivan
Copy link
Owner

@MATRIX4284, I'm going to assume your issue has been resolved and close this issue. Please reach out if you are still having issues

@MATRIX4284
Copy link
Author

@MATRIX4284, I'm going to assume your issue has been resolved and close this issue. Please reach out if you are still having issues

Hi @banesullivan @giswqs thanks for you support .Now i can see my tiles in jupyter .Thanks a ton

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

3 participants