Comments (16)
It's as simple as:
from localtileserver import get_leaflet_tile_layer, examples, TileClient
from ipyleaflet import Map
client = TileClient(examples.get_data_path("bahamas_rgb.tif"))
client.client_host = f'localhost:{client.server.port}'
t = get_leaflet_tile_layer(client)
m = Map(center=client.center(), zoom=client.default_zoom)
m.add_layer(t)
m
But I'll make this a little easier in the next release
from localtileserver.
yeah... ran into that too... Google Colab installs GDAL and their build is wack (and missing that module). This was handled in afe669c and will be good on the next release
from localtileserver.
The reason it works is actually pretty specific to colab supporting this localhost
remapping. Reference https://colab.research.google.com/notebooks/snippets/advanced_outputs.ipynb
Outputs in the browser can request resources from the kernel by requesting https://localhost:{port}. The protocol will automatically be translated from https to http and the localhost will be the kernel executing the code.
from localtileserver.
@giswqs, it's been a long time since I've used Colab. Could you post a link to a repo and session I could launch to debug this?
from localtileserver.
Here it is
https://colab.research.google.com/drive/1tWU1Th_qmOLbixbW2HUCUW7eXEvf0Xgs?usp=sharing
from localtileserver.
I have no idea how to do this on google colab. It's seemingly not a Jupyter Hub/Lab instance and I have absolutely no idea how to expose a port on the runner. jupyter-server-proxy
is really the only safe way to do this in cloud environments and I don't think that's possible with google colab
from localtileserver.
This is actually really easy! I figured it out while trying to get this to work for PyVista in pyvista/pyvista#3851
I'll see if I can add support directly in localtileserver
from localtileserver.
@banesullivan That's awesome to hear. Can't wait to try it out.
from localtileserver.
Excited to try this out. Got an error. I should probably wait for the next release.
from localtileserver.
So, this is fixed by de4d2ef
What do you think, @giswqs?
from localtileserver import get_leaflet_tile_layer, examples, TileClient
from ipyleaflet import Map
path = examples.get_data_path("bahamas_rgb.tif")
client = TileClient(path)
client.enable_colab()
t = get_leaflet_tile_layer(client)
m = Map(center=client.center(), zoom=client.default_zoom)
m.add_layer(t)
m
from localtileserver.
This gives me hope that localtileserver might work with all major Jupyter notebook platforms, including AWS SageMaker.
client.client_host = f'localhost:{client.server.port}'
from localtileserver.
You may not need that client.enable_colab()
explicitly. You might be able to integrate this into TileClient
.
import sys
if "google.colab" in sys.modules:
self.client_host = "localhost"
self.client_port = True
from localtileserver.
Ah, good point. This assumes google.clolab
is only ever installed on colab... which is probably a safe assumption
from localtileserver.
Correct. The google.colab
module can only be found on Colab. That module can't be found on any other Jupyter platforms or local computers.
from localtileserver.
Check out https://colab.research.google.com/drive/1h1iTDl4KqbXxKiyox9eM211vAg6_ONKT?usp=sharing (you have to restart the runtime after installing localtileserver
)
0.6.4
now autodetects google colab and all should work
from localtileserver.
It worked like a charm! Thank you very much for this!
from localtileserver.
Related Issues (20)
- Use localtileserver in a docker container HOT 1
- Error: NeededInitPrefix is not defined HOT 4
- add_raster() isn't adding the downloaded image into the map HOT 15
- add_layer doesn't work with GeoTIFF file converted from xarray Dataset HOT 11
- can't add local raster file in windows HOT 4
- Use ipyleaflet's as_leaflet_layer interface
- Cannot display raster in Google Colab HOT 5
- Generated PNG tiles are not transparent (have black background) HOT 3
- Remote COG no longer works HOT 4
- Tiff file saving to HTML using folium HOT 1
- Tileclient does not show when run dash app python on docker HOT 3
- localtileserver fails with flask==3 HOT 2
- localtileserver not working with Leafmap on Docker HOT 4
- localtileserver client cannot work after setting the http proxy HOT 4
- not working on VS code remote notebook HOT 1
- Passing rasterio.Env context to tile server HOT 5
- nodata causes padding HOT 15
- The vmin and vmax parameters have no effect HOT 2
- Support custom colormaps
- Generate thumbnails in a projection
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from localtileserver.