Closed damianooldoni closed 2 years ago
After breaking my head to add zero as special value as stated here, I came to the idea that actually it is not completely right to define 0 as a special value as all variables we want to visualize are continuous! The transitions should be smooth. So, it's just a matter of defining a specific color palette which starts from black.
We can use already predefined palettes with black as extreme value. These are:
We can otherwise make our own palette, not a big deal, just choosing the color we want to pass through, e.g. by passing palette_colors <- c("black", "green", "blue")
to arg palette
in leaflet::colorNumeric()
function
@jimcasaer: give a look to examples below please and tell me which one do you like it most? Are you satisfied with one of these palettes?
Extreme values:
Middle range values:
Extreme values:
Middle range values:
Extreme values:
Middle range values:
I think also that the choice of the palette should still be left to the user by adding the argument palette
to map_dep()
.
@jimcasaer: the choice of the favourite palette (see comment above) is sitll important as we can use it as default palette.
Update: I implemented my solution in #80 and merged to main
branch so everybody can test it easily by installing the package. Default palette: "inferno"
.
@damianooldoni sorry for the long delay before taking this up when do you have 5 minutes to discuss this before approving?
We decided to try to get a second layer with only the zeros and those ones with a special marker or symbol. In this way are the zero values easily detectable.
@jimcasaer: in #84 I tackled this issue again. Can you give a look to the results as shown in vignette: https://inbo.github.io/camtrapdp/articles/visualize-deployment-features.html
If you are satisfied with this kind of marker, we can close this issue and give a party 🥳
hmm, the markers are very big !! and blur the total view of the map -- so to be honest: not yet fully satisfied no party time yet
what about using simple circle markers in a specific color for the subset of locations with "0" values
Ok. So, the markers should be scalable like the other circles. Notice I leave the continuous scale in legend from 0 but the values mapped in the legend are all data without 0. This to allow visualizing values which are almost 0 but not 0.
Let's see what you prefer:
gray circle markers, with stroke, default opacity
gray circle markers, with stroke, fillOpacity = 0.8, opacity of the stroke = 0.8
gray circle markers, without stroke, fillOpacity = 0.8
black circle markers, with stroke, standard opacity
@jimcasaer: let me know which options you like at most, so I can provide you more examples. It's like selling a suit 😄
@damianooldoni preference for option 4 -- only wondering if red or white would not be better given the background colours of the maps
the suit is almost sold, difficult client
Let's give a try!
default opacity is way too low, I think.
Better, but it doesn't stand out, I think.
Personally I find red with high opacity the best one. But, be careful: it's the best one if we use default palette! If a user opts for example for `palette = "reds", I think making red circles is not the best option anymore.
Proposal: as we allow the user to pass a different palette than the default one, I strongly recommend to allow him/her to define also the color of these new circles if red is not good.
damiano,
my personal preference is the red - default opacity :-) and yes I like the idea of to have a default palette and default red -- but allowing the user to indicate other palettes and other colours
Great! I will do.
@jimcasaer: done and merged to main in #86. Online documentation and vignette should be automatically updated on the website within few minutes. Let me know what do you think about it.
could it be that the red inside/outside is reversed in comparison to example 3 ?
I have just given a look to the leaflet maps in https://inbo.github.io/camtrapdp/articles/visualize-deployment-features.html It seems everything works as expected. The stroke is more opaque than the circle as expected. Or would you like less opacity of the inner circle in general?
very strange -- my leaflet does the opposite -- when do you have 5 minutes ?
works fine now outside of markdown -- :-) final ideas
The cluster option already exists. By default is cluster = TRUE
. You can deactivate clustering via cluster = FALSE
. it's very easy to add clustering to cluster deployments with zero values as well.
But I would avoid to allow a mix behavior, i.e. cluster = TRUE
for deploys with zero values and cluster = FALSE
for all other deployments or viceversa. It will result in adding another argument to the function and I don't think you will ever user it. Do you agree on this?
I think I misunderstood your request in my previous comment., @jimcasaer. We can cluster zero values deploys and non zero values deploys apart (as explained in my comment above, and as I will push on main in a while). But we can NOT cluster zero and non-zero values deploys together as they are two different layers, indeed.
A small but maybe important graphic decision.
Do you prefer non-zero deploys on top of zero ones (option 1):
Or viceversa (option 2)?
I think option 1, but I would like your opinion on this. Thanks.
@jimcasaer: Pull Request #87 implements option 1 as described in my comment above. Give me your ok and I can push it to main.
when do you have a moment looks like clustering is not working on both layers
Well, @jimcasaer, it cannot work on main branch as I have still not pushed to main. Should I?
after videocall with @jimcasaer we decided to go for option 1. Unfortunately the merged PR #87 implemented the worng option (option 2). A fast PR is following.
@jimcasaer: does everything work fine now? I hope so. Please let me know. Hopefully we can close this issue.
you can close it :-) good start for the weekend
After @jimcasaer brainstorming with his colleagues, we decided to:
@jimcasaer:
library(dplyr)
library(camtrapdp)
# icon from https://icons8.com/icons/set/math
# red (E74C3C) - 10px
icons <- leaflet::icons(
iconUrl = "https://img.icons8.com/ios-glyphs/30/E74C3C/multiply.png",
iconWidth = 10,
iconHeight = 10
)
leaflet::leaflet(mica$deployments) %>%
leaflet::addTiles() %>%
leaflet::addMarkers(icon = icons)
#> Assuming "longitude" and "latitude" are longitude and latitude, respectively
# black (000000) - 15px
icons <- leaflet::icons(
iconUrl = "https://img.icons8.com/ios-glyphs/30/000000/multiply.png",
iconWidth = 15,
iconHeight = 15
)
leaflet::leaflet(mica$deployments) %>%
leaflet::addTiles() %>%
leaflet::addMarkers(icon = icons)
#> Assuming "longitude" and "latitude" are longitude and latitude, respectively
# yellow (F1C40F) - 20px
icons <- leaflet::icons(
iconUrl = "https://img.icons8.com/ios-glyphs/30/F1C40F/multiply.png",
iconWidth = 20,
iconHeight = 20
)
leaflet::leaflet(mica$deployments) %>%
leaflet::addTiles() %>%
leaflet::addMarkers(icon = icons)
#> Assuming "longitude" and "latitude" are longitude and latitude, respectively
# white (FFFFFF) - 25px
icons <- leaflet::icons(
iconUrl = "https://img.icons8.com/ios-glyphs/30/FFFFFF/multiply.png",
iconWidth = 25,
iconHeight = 25
)
leaflet::leaflet(mica$deployments) %>%
leaflet::addTiles() %>%
leaflet::addMarkers(icon = icons)
#> Assuming "longitude" and "latitude" are longitude and latitude, respectively
Created on 2022-03-15 by the reprex package (v2.0.1)
given the standard palette used in map_dep I would suggest to go for a default black and for the smallest symbol (and now I hope the female part of our team will agree :-) )
Thanks a lot. Could you please check this with your team (or its female part of it) and give me the final GO?
@damianooldoni cluster = FALSE seems to give an error when using map_dep
Yes, you are right. I tried to change this
clusterOptions = if (cluster == TRUE) leaflet::markerClusterOptions() else NULL
with this:
clusterOptions = ifelse(cluster == TRUE,
leaflet::markerClusterOptions(),
NULL
)
but R said NO 😄
I revert it and everything should look good again.
Done in https://github.com/inbo/camtraptor/commit/7039d97445e699c2f8acccec7e6402d162ce4265 directly on main
. Please reinstall and let me know.
the result is great !! thanks adapted icon size to 5
After meeting with @jimcasaer, we decided to give color black to value 0 in
map_dep()
as it is a special/sentinel value. This should affect the visualization of all features (rai, n_species, effort, n_obs)