tmap inner border colour based on region

25 views Asked by At

From my previous question I got help to label border regions by different colours. However the issue I'm noticing is as the borders are plotted, they overlap and block other borders.

library(sf)
library(bcmaps)
library(dplyr)
library(tmap)

ha_shape <- bcmaps::health_ha() %>% rename_with(tolower, everything())

tm_shape(ha_shape) +
  tm_polygons(
    col = "hlth_authority_name", 
    palette = c(
    "Interior" = "#3891A7", 
    "Fraser" = "#C3860D", 
    "Vancouver Coastal" = "#C42E2E", 
    "Vancouver Island" = "#67A63C", 
    "Northern" = "#914FAB"), 
    alpha = 0.3
    ) +
  tm_shape(ha_shape %>% st_cast("MULTILINESTRING")) +
  tm_lines(col = "hlth_authority_name", 
           lwd = 1, 
           palette = c(
             "Interior" = "#3891A7", 
             "Fraser" = "#C3860D", 
             "Vancouver Coastal" = "#C42E2E", 
             "Vancouver Island" = "#67A63C", 
             "Northern" = "#914FAB")
           alpha = 0.8)

enter image description here

Ideally what I'd like to do is have a thin black border line, and just inside it have a thin line with the same colour as the fill, just a higher alpha so it appears a bit darker. I'm assuming I'll need to do some kind of operation with the geometries to make an internal line for each polygon and then colour that? Not really sure how to tackle.

Any help would be appreciated!

0

There are 0 answers