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

mismatched colors in legend for raster (similar to issue 362 but unresolved for raster?) #439

Open
geocaruso opened this issue Aug 28, 2022 · 6 comments

Comments

@geocaruso
Copy link

Hello and thanks for this great package, so useful to explore maps while developing a piece of code

I encounter a problem, which I believe is similar to 362, which was resolved, but maybe not for raster layers?

I have a raster layer with 3 values: 2001,2008,2019
image

If I run mapview with 3 colours: red for 2001, blue for 2008 and green for 2019, I get a legend with interpolated colour (purple) for the 2001 value. The other two colours being correct on the map.
image

The warning indeed informs me I have 4 values but there is actually only 3 (all zeroes were previously sent to NA and are thus transparent)

unique(urbanyear)
[1] 2001 2008 2019

I can obtain the map I want if I add a fourth colour, i.e. yellow in this example, but then the legend no longer corresponds. The last one (green) is not in
image

Looks like mapview believes there is another, smaller ,value in the raster, but there are none, which the legend seems to get correct in terms of values, not colours

(sorry if this not std process for reporting, this is actually 1st time ever I report an issue with github)
Thanks for great work and any help
Geoffrey

@tim-salabim
Copy link
Member

What happens if you add method = "ngb" to the mapview call?

@geocaruso
Copy link
Author

No difference.
image

@tim-salabim
Copy link
Member

Ok, I think the problem is that you actually want a factorial raster rather than a numeric one. Can you provide the data for me to look into it deeper?

@geocaruso
Copy link
Author

Sure. You should be able to download then load the raster as an R obj (to avoid conversion to tif) from here
https://www.dropbox.com/s/grqn2w0ttw3x3e9/urbanyear?dl=0

@tim-salabim
Copy link
Member

Thanks. I am travelling today so will probably not be able to look at it until tomorrow

@geocaruso
Copy link
Author

Have a safe trip! Thanks!

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