Closed giswqs closed 2 years ago
Most of this pertains to the upstream large_image package
How are vmin and vmax determined when plotting a single band with vmin=None and vmax=None?
They are determined with GDAL's GetStatistics()
method directly: https://github.com/girder/large_image/blob/1b537a1fef5326721f2c8048361aba3d9f702656/sources/gdal/large_image_source_gdal/__init__.py#L522-L525
Check out GetStatistics()
's documentation for some additional features it provides
Are they derived from TileClient.metadata()["bands"] when users do not specify the values?
Exactly, yes
From the documentation, it seems vmin and vmax only support single-band imagery. How about multi-band imagery?
Hm, the documentation is lacking here for sure. These are actually supported for multi-band imagery. Here is an example:
from localtileserver import get_leaflet_tile_layer
from localtileserver import examples
from ipyleaflet import Map
tile_client = examples.get_san_francisco()
t = get_leaflet_tile_layer(tile_client, band=[1,2,3], palette=['r', 'g', 'b'], vmin=[0,0,0], vmax=[100,200,10])
m = Map(center=tile_client.center(), zoom=9)
m.add_layer(t)
m
This scales each band in it's vmin/vmax range before mapping to the pallete for it's channel.
When plotting multi-band imagery using titiler, I use the percentile_2 and percentile_98 as the default vmin and vmax.
The percentile_*
feature would be a great addition to large_image! Perhaps we should open a feature request there
Thank you for the example. Great to know that it works multi-band imagery. I am implementing a GUI for loading raster in leafmap without coding.
https://user-images.githubusercontent.com/5016453/148656102-cff398f9-9eeb-4dc2-8974-9a35a2536a8e.mp4
How are
vmin
andvmax
determined when plotting a single band withvmin=None
andvmax=None
? Are they derived fromTileClient.metadata()["bands"]
when users do not specify the values?From the documentation, it seems
vmin
andvmax
only support single-band imagery. How about multi-band imagery?When plotting multi-band imagery using titiler, I use the
percentile_2
andpercentile_98
as the defaultvmin
andvmax
. https://github.com/giswqs/leafmap/blob/8bd65d9b42c0629d60b55f194d7e50ec04d9162a/leafmap/common.py#L979-L983https://leafmap.org/notebooks/37_planetary_computer/