-
Notifications
You must be signed in to change notification settings - Fork 362
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
ImageOverlay or TileLayer with local files #234
Comments
Did you try without the "file://" in the URL? |
Can you try |
that doesn´t work either unfortunately. |
Ok, do you have an error displayed in the Javascript console when trying to add the |
Also, what browser are you using? If you are using Chome/Chromium, can you try with Firefox? |
i will ask my admin to install a different browser than chrome and try again. |
Ok, so it founds the file. You're just not allowed to load it for security reasons. I guess that's because you're using Chrome. And maybe it could work on Firefox, but I'm not entirely sure. |
I think LeafletJS only support PNG and JPG image files. I guess you would need to convert your images first. You can do that programmatically on linux https://askubuntu.com/a/60410 |
The conversion to .png or .jpg does not seem to make any difference. The tiles are still showing blank. Update: I just ended up hosting a local http server: |
Hello, I have encountered the same issue. I would like to load a raster file (tiff) into ipyleaflet from my local machine. Loading a tiff (as LocalTileLayer) does not show anything. Converting the raster to png loaded the file but it is now displayed as many tiles all over the map as you can see below. Is there a way to load raster files properly into ipyleaflet? (@giswqs, is there a way to do it implemented in geemap? I could not find anything right now...) Alternatively, could an array be displayed in ipyleaflet? Thanks for your support! |
@AlexanderJuestel Yes, you can use image_overlay() with geemap to load a local png file to the map. Check out this notebook example. |
@AlexanderJuestel ipyleaflet can also do image overlay using relative file path. |
@giswqs thanks for the quick answer. I tried it with pure ipyleaflet and with the geemap implementation and it works fairly well (first image). However, I noticed when I am using my own implementation, that the default map gets deactivated for some reason and that dragging does not work anymore (second image). What I am currently doing is passing an WMS Layer, extracting a certain area and save it as image file. This image file, which could also be a high res DEM for instance should then be displaced in the map for further manipulation/processing. If you need more information for this particular problem, let me know. |
Is the basemap still listed under the layer control on your second image? Did you accidentally clear all layers before adding the local image? |
Hello @giswqs, for some reason everything works perfectly again and as expected :) Thanks again for the help! |
Question moved to issue #604. Sorry for the inconvenience. |
The discussion is drifting away from the original purpose of the issue. Would you mind opening another issue or ask your question on another channel? |
I'm still having this issue. If I use a relative local path, I don't get any errors in the console, but get a blank image outline like in #234 (comment). If I spawn a local file server
|
Thought I'd chime in and give a plug for something I developed to solve the issue of viewing local raster files with ipyleaflet: https://github.com/banesullivan/localtileserver In essence, it's a little package that will launch a local tile server in a background thread for use with ipyleaflet. Check out the README for an example, (the code here is subject to change): from localtileserver import get_leaflet_tile_layer
from ipyleaflet import Map, ScaleControl, FullScreenControl, SplitMapControl
m = Map(
center=(37.7249511580583, -122.27230466902257),
zoom=9, crs=projections.EPSG3857,
)
# Create two tile layers from 2 seperate raster files
l = get_leaflet_tile_layer('~/Desktop/TC_NG_SFBay_US_Geo.tif',
band=1, palette='matplotlib.Viridis_20', vmin=50, vmax=200)
r = get_leaflet_tile_layer('~/Desktop/small.tif',
band=2, palette='matplotlib.Plasma_6', vmin=0, vmax=150)
control = SplitMapControl(left_layer=l, right_layer=r)
m.add_control(control)
m.add_control(ScaleControl(position='bottomleft'))
m.add_control(FullScreenControl())
m |
I was trying the Velocity demo with a smaller wind dataset and would like to add a local file rasters (higher quality terrain hillshade) or a local Tilemap I created with QGIS to the map. Those files are on a different drive though, and I can´t figure out how to get them to display. It seems absolute paths don´t work even if I try it with the same file I use for the relative path:
How can I point to a local file or a Tilemap and get it to display?
The text was updated successfully, but these errors were encountered: