Home > Software engineering >  Base Map using ggplot2 for any country
Base Map using ggplot2 for any country

Time:09-22

How to choose a specific country (like Seychelles) to create a base map in background using map_data() function in ggplot2. Is there another function to retrieve polygones of countries?

CodePudding user response:

check maps package

maps::map('world', regions = "Seychelles")

enter image description here

CodePudding user response:

You can get a higher resolution map using the rnaturalearth package:

library(rnaturalearth)
library(dplyr)

ne_countries(scale = 10, returnclass = 'sf') %>%
  filter(geounit == "Seychelles") %>%
  ggplot()  
  geom_sf(fill = "#e0e8a0")  
  ylim(c(-5, -4))  
  xlim(c(-55, -56))  
  theme(panel.background = element_rect(fill = "#8088d0"),
        panel.grid = element_line(size = 0.1))

enter image description here

  • Related