[DONE] Gradient Colormaps #299
Replies: 2 comments 3 replies
-
@aliasmrchips for now this is not supported natively via query_parameters. In order to support this we would have to add ndvi = matplotlib.colors.LinearSegmentedColormap.from_list(
'ndvi', [
'#422112',
'#724C01',
'#CEA712',
'#FFA904',
'#FDFE00',
'#E6EC06',
'#BACF00',
'#8BB001',
'#72A002',
'#5B8D03',
'#448102',
'#2C7001',
'#176100',
],
256,
)
x = numpy.linspace(0, 1, 256)
cmap_vals = ndvi(x)[:, :]
cmap_uint8 = (cmap_vals * 255).astype('uint8')
ndvi_dict = {idx: value.tolist() for idx, value in enumerate(cmap_uint8)} previous discussion: #153 We could think about a user wanted to do something like: cmap = urlencode(
{
"colormap": json.dumps(
{
"1": "#FFFFFFFF",
"10": "#AEFBFFFF",
...
"255": "#ddcb9aFF",
}
)
}
)
response = app.get(
f"/cog/tiles/8/53/50.png?url=https://myurl.com/cog.tif&bidx=1&{cmap}&colormap_type=linear"
) For now I can add an example https://github.com/developmentseed/titiler/tree/master/docs/examples/code |
Beta Was this translation helpful? Give feedback.
-
@vincentsarago Is this still the correct way to do this? I noticed that the current version gets the ColorMapType enum from rio-tiler, e.g., |
Beta Was this translation helpful? Give feedback.
-
How would you pass in a gradient colormap, like "viridis" (if it was not a named colormap), for example?
Beta Was this translation helpful? Give feedback.
All reactions