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

When using addGeoRaster viridis color palette, how do you create a matching legend? #55

Closed
jzadra opened this issue Mar 17, 2022 · 2 comments

Comments

@jzadra
Copy link

jzadra commented Mar 17, 2022

Following the example in #25 where viridisLite::inferno is used in the colorOptions, what is the best way to add a legend with that palette?

I've tried:

pal <- colorNumeric(viridisLite::inferno, domain = values(myraster),
                    na.color = "transparent")
 addLegend(pal = pal, values = values(myraster))

as well as

 addLegend(pal = viridisLite::inferno, values = values(myraster))

And neither work.

@tim-salabim
Copy link
Member

Hi, I think you need to explicitly set how many colors you want to generate. This works for me:

pal = colorNumeric(
  viridisLite::inferno(256)
  , domain = tst[[1]]
  , na.color = "transparent"
)

@jzadra
Copy link
Author

jzadra commented Mar 18, 2022

Works for me too! Thanks.

@jzadra jzadra closed this as completed Mar 18, 2022
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

2 participants