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

User specified "custom" colormap #153

Closed
blazetopher opened this issue Nov 19, 2020 · 3 comments · Fixed by #262
Closed

User specified "custom" colormap #153

blazetopher opened this issue Nov 19, 2020 · 3 comments · Fixed by #262
Labels
enhancement New feature or request

Comments

@blazetopher
Copy link

Is there a way to allow the client to specify a custom colormap "dynamically"? For example, by providing a series of pixel+color pairs and dynamically generating a linear gradient colormap on the fly during rendering?

If such a capability doesn't exist, would you have any advice on how it might be best implemented?

@vincentsarago
Copy link
Member

vincentsarago commented Nov 19, 2020

Hey @blazetopher thanks for opening the issue.
Sadly there is no such capability, It was been in my mind for a long time now but I cannot think of a good way to do it.

I think there are 2 solutions:

  1. the user provide the dynamic color_map info in each request
https://myendpoint/cog/preview?&url={myfile}&color_map={0: [0, 255, 255, 0], 2: ..., 3: ...}&color_map_type=linear|discrete 
  1. user define a colormap and POST it to the backend (which store it in a DB or in a shared drive like efs)

Solution 2 is really complex and might not even be possible, so solution 1 might be better. That's say I'm not 💯 on solution 1 because it will lead to really long/complex URL 🤷‍♂️

if we add this, this is where it should happen https://github.com/developmentseed/titiler/blob/master/titiler/dependencies.py#L219-L246

ref: https://terracotta-python.readthedocs.io/en/latest/tutorials/categorical.html?highlight=colormap#in-the-frontend

@vincentsarago vincentsarago added the enhancement New feature or request label Nov 19, 2020
@blazetopher
Copy link
Author

@vincentsarago Thanks for the rapid response!

I was also thinking something along the lines of Option 1. Our use case is relatively straightforward: Only 3 colors and 2 splits - no gradients. So while that case theoretically wouldn't be too bad, specifying every pixel value would get complex quickly. Also sounds like there would potentially be encoding/decoding requirements (based on the terracotta reference) to take into consideration.

Thanks also for the pointer to the proper location in the codebase. I'm unsure if our current project timeline will allow for it, but if we end up trying to implement and it comes out well, I'll be sure to submit a PR so it can be folded back in!

@kylebarron
Copy link
Member

I think it would be fine to allow a colormap argument to not include all 255 colors, as long as it's understood the colors will be split evenly. So if you had 40 numbers in a row, that could define a colormap with 10 sections, and would be less of a URL burden. But with non-categorical colormaps only definining a few colors might not be possible.

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

Successfully merging a pull request may close this issue.

3 participants