mapview icon indicating copy to clipboard operation
mapview copied to clipboard

cex seems to be not a fix value to control the size of points

Open StatistikVolker opened this issue 4 years ago • 2 comments

Good New Year! Thank you for your mapview Package. Actually I want to show on a map CoVid19 cases. I have the adresses of each case. I plot for each case a piont on the map. This works fine! Some adresses have more than one case (e.g. one familiy). therefor I want to control the size of the points via the cex-option. This again workes fine for each single map.

But a cex = 1 in one map does not automatically mean that points with cex = 1 in the next map (eg. the next day) have the same size. How can I control it, that cex=1 is the same size for each map (day)?

Simple examples:

breweries1 <- breweries %>% filter(number.of.types == 1)
mapview(breweries1, cex = "number.of.types")
breweries2 <- breweries %>% filter(number.of.types < 3)
mapview(breweries2, cex = "number.of.types")

Thank you for any help!

Greetings, V

StatistikVolker avatar Jan 06 '21 15:01 StatistikVolker

@StatistikVolker thanks for bringing this up. There is currently a discrepancy between fgb rendering mode and classic rendering mode where the former does not respect arguments min.rad & max.rad. As a workaround you can set mapviewOptions(fgb = FALSE):

library(mapview)
library(dplyr)

mapviewOptions(fgb = FALSE)

breweries1 <- breweries %>% filter(number.of.types == 1)
mapview(breweries1, cex = 10) # supply cex directly as only one size
breweries2 <- breweries %>% filter(number.of.types < 3)
mapview(breweries2, cex = "number.of.types", min.rad = 10, max.rad = 20)

I will support this in fgb rendering mode soon.

tim-salabim avatar Jan 07 '21 12:01 tim-salabim

Brilliant @tim-salabim: it works! I recommend not to have a cex below 2, because cex = 1 is in this solution very small. And I defined min.rad and max.rad like this:

library(mapview)
library(dplyr)

mapviewOptions(fgb = FALSE)

breweries2 <- breweries %>% filter(number.of.types < 3)
cexmin = min(breweries2$number.of.types) + 1
cexmax = max(breweries2$number.of.type) + 1
mapview(breweries2, cex = "number.of.types", min.rad = cexmin, max.rad = cexmax)

Thank you for adding the required packages as well :-)

StatistikVolker avatar Jan 07 '21 14:01 StatistikVolker