rleafletpointr-mapview

Standardising point size across groups


Using zcol, cex and burst it is possible to adjust the size of all levels within a point layer in mapview. However, the size of each point is relative only to the size of other points WITHIN that same level. For example, in the following code, the size of a point with number.of.types value 14 in group a is the same as number.of.types value 6 in group b.

library(tidyverse)
library(tidyr)
library(mapview)

b = breweries %>% 
  drop_na(number.of.types) %>% 
  mutate(group = ifelse(number.of.types >= 7,"a","b"))

b %>%
  mapview(zcol="group", cex="number.of.types", burst=T)

Is it possible to standardise the size of points across levels without resorting to having to define this for each layer level individually?


Solution

  • update

    I just discovered that setting the burst-argument to FALSE seems to do the trick?

    b %>%
      mapview(zcol="group", cex="number.of.types", burst=FALSE)
    

    enter image description here

    previous answer

    I'm not sure about mapview-options, since I rarely use the function.

    You could try reprocuding the map you desire with leaflet (which is what mapview uses if I remember correctly).

    It requires a bit more lines of code though..

    library(leaflet)
    
    colorGroup <- colorFactor( topo.colors( 2 ), b$group )
    
    leaflet() %>% addTiles() %>%
      addCircleMarkers( data  = b,
                        #circle size
                        radius  = ~number.of.types,
                        #circle borders
                        color = "black", opacity = 1, stroke = TRUE, weight = 2,
                        #circle inside
                        fillColor = ~ colorGroup( group ), fillOpacity = 0.8 ) 
    

    results in

    enter image description here

    And you would have to add code for legend and popups (if needed).