Open hillsonghimire opened 10 months ago
Hi @hillsonghimire,
As far as I know, most browsers cannot display tiff images directly. Without making changes to ipyleaflet
to include bindings to e.g. GeoRaster
, you could:
1) convert the raster to png following @giswqs's example here
import io
import base64
import PIL.Image
# convert geotiff image to in-memory png
f = PIL.Image.open('/content/LC08_L1TP_126049_20200301_20200313_01_T1_B1.TIF')
png = io.BytesIO()
f.save(png, format='png')
png.seek(0)
# encode to base64 and get url
data = base64.b64encode(png.read()).decode('ascii')
url = "data:image/png;base64," + data
# visualize with ImageOverlay
overlay = ImageOverlay(url=url, bounds=((bottom, left), (top, right)))
2) use the tile layer functionality as outlined by @banesullivan here
I think adding bindings for GeoRaster
might be a good long-term fix, but this should work in the mean time. Hope this helps.
It is recommended to add a raster dataset as a tile layer with localtileserver rather than using ImageOverlay. See this example: https://leafmap.org/notebooks/32_local_tile
agreed.
More examples: https://geoai.gishub.org/examples/dataviz/raster_viz
I tried the following code to visualize a single band raster image form landsat 8, but the image cannot render over the map. The broken thumbnail appears over the map layer.
I am using google colab as notebook server.