0

how would I go about adding a different type of border line between two regions? I am using NUTS2 data and want to add some kind of differentiation (a thicker line, or a different colour, etc) between West and East Germany. I am using ggplot2 in R.

Here is my code to create the map I have so far, and I have also attached a picture of what this code produces, and ideally would like a thicker border line between the green and blue areas.

# Data files from: https://censusmosaic.demog.berkeley.edu/data/historical-gis-files
germany_shapes_1990 <- st_read("Federal Republic of Germany 1990-2009/Germany_1990_91_v.1.0.shp",
                               layer="Germany_1990_91_v.1.0")
# Read-in persent shapes
nuts_shapes <- st_read("NUTS_RG_20M_2016_4326.shp",
                       layer="NUTS_RG_20M_2016_4326")

# Transform NUTS shapes- Germany
nuts_shapes_germ <- st_transform(nuts_shapes, st_crs(germany_shapes_1990))

# Keep NUTS2 only
nuts_shapes_germ<- filter(nuts_shapes_germ,
                           LEVL_CODE == 2)

# Keep Germany only
nuts_shapes_germ <- nuts_shapes_germ %>% filter(grepl('DE', NUTS_ID))

####################
# 5. The year 1990 #
####################

# Clean the old map
germ_shapes_1990 <- germ_clean_1990 %>% 

#add east vs west
#note regress dat- from dataprep script
east_west <- regress_dat %>%
  select(user_loc,user_country_1990) %>%
  distinct(user_loc, .keep_all=TRUE)
           
ew_germ_shapes <- nuts_shapes_germ %>%
  left_join(east_west, by=c(NUTS_ID = "user_loc")) %>%
  drop_na(user_country_1990)

#Rename 
ew_germ_shapes$user_country_1990[ew_germ_shapes$user_country_1990 == "DE"] <- "West Germany"
ew_germ_shapes$user_country_1990[ew_germ_shapes$user_country_1990 == "GC"] <- "East Germany"

regions <- ew_germ_shapes$user_country_1990
palette <- distinctColorPalette(length(regions))

#Basic Map Germany
basic_germ_map <- ew_germ_shapes %>%
  ggplot() + geom_sf(aes(fill=regions)) +
  scale_fill_manual(values=palette) + 
  ggtitle("1990 Germany in Modern NUTS2") +
  theme(legend.key.size = unit(2,'cm'), legend.text = element_text(size=10))

basic_germ_map

West/East Germany Map

tjebo
  • 21,977
  • 7
  • 58
  • 94
  • Does this answer your question? [Border line around a group of certain countries in a map](https://stackoverflow.com/questions/64262412/border-line-around-a-group-of-certain-countries-in-a-map) – harre Jun 07 '22 at 15:53
  • 1
    Especially the last part on how to **remove internal boundaries in sf-object** using `sf::st_union()`. You need to do the opposite :-) – harre Jun 07 '22 at 15:54
  • 1
    very related https://stackoverflow.com/questions/70349542/how-can-i-change-the-color-of-a-shared-border-using-sf – tjebo Jun 07 '22 at 16:23

0 Answers0