Skip to content
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

Accommodate custom color maps for EPA datasets #203

Closed
1 task
j08lue opened this issue Oct 5, 2023 · 7 comments
Closed
1 task

Accommodate custom color maps for EPA datasets #203

j08lue opened this issue Oct 5, 2023 · 7 comments
Assignees

Comments

@j08lue
Copy link
Collaborator

j08lue commented Oct 5, 2023

Requested color ramp:

my_cmap = colors.LinearSegmentedColormap.from_list(name='my_cmap',colors=['#6F4C9B', '#6059A9', '#5568B8', '#4E79C5', '#4D8AC6',
'#4E96BC', '#549EB3', '#59A5A9', '#60AB9E', '#69B190',
'#77B77D', '#8CBC68', '#A6BE54', '#BEBC48', '#D1B541',
'#DDAA3C', '#E49C39', '#E78C35', '#E67932', '#E4632D',
'#DF4828', '#DA2222', '#B8221E', '#95211B', '#721E17',
'#521A13'],N=3000)
my_cmap._init()

slopen = 200
alphas_slope = np.abs(np.linspace(0, 1.0, slopen))
alphas_stable = np.ones(3003-slopen)
alphas = np.concatenate((alphas_slope, alphas_stable))
my_cmap._lut[:,-1] = alphas
my_cmap.set_under('white', alpha=0)
  1. If possible, please plot 'zeros' in the dataset as opaque colors (this will result in no transparent grid cells).
  2. Please plot all data layers (both individual sources and aggregate layers) on the same color ramp, with MINIMUM set to zero and the MAXIMUM set to 2x10^12 molec/cm2/s.

Acceptance criteria

  • Found out how to render this color map (or something equivalent), opened new tickets if upstream changes (in TiTiler or so) are needed
@j08lue
Copy link
Collaborator Author

j08lue commented Oct 5, 2023

Tagged you here, @slesaad and @siddharth0248, but please consult Dashboard folks when you pick this up.

@slesaad
Copy link
Collaborator

slesaad commented Oct 10, 2023

Hey @j08lue, we couldn't find a way to implement this colormap. We looked at different options with the colormap query parameter.

  1. Discrete colormap - one color for one value - obviously won't work since the values are not discrete
  2. Interval colormap - one color or range of values - won't work either
  3. Linear colormap - I think this is what we're looking for but it looks like it needs a color each for values 0-255, however, that big of dictionary exceeds the limit of maximum URL length. But also I don't think I fully understand how to use this. Since the value of the file range from 0-500 for example, do we rescale this to 0-255 and then send those value (if the max url length limit didn't exist)?

Might need some help implementing this if it is even possible currently! 😅

@j08lue
Copy link
Collaborator Author

j08lue commented Oct 11, 2023

Maybe @vincentsarago can shed light on what is possible?

Perhaps this is not possible via URL (client) parameters but with a custom colormap we register in rio-tiler or something?

Please document here what you have tried, @slesaad, which will make it easier to reproduce and find alternatives.

@vincentsarago
Copy link

see https://developmentseed.org/titiler/examples/code/tiler_with_custom_colormap/

But also I don't think I fully understand how to use this. Since the value of the file range from 0-500 for example, do we rescale this to 0-255 and then send those value (if the max url length limit didn't exist)?

@slesaad, yes you need to rescale the values from 0 to 255 (using rescale=0,500).

@Jeanne-le-Roux
Copy link

Just a note that Erin would still like us to implement this custom color ramp, but wants to make sure that the zero values are white.

@slesaad
Copy link
Collaborator

slesaad commented Nov 7, 2023

Tested the new colormap from the above pr ^. It looks mostly good to me.

total-agriculture, year 2018 (left custom colormap in the dashboard, right official paper)
image

@j08lue
Copy link
Collaborator Author

j08lue commented Nov 8, 2023

Awesome, that is very convincing, @slesaad! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants