Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(ggplot2)
- library(rgdal)
- library(sp)
- smap1 <- readOGR("C:/Users/idan.benaun/Downloads/NGA_adm_shp/NGA_adm1.shp")
- smap1_df <- fortify(smap1, region = "NAME_1")
- idList <- smap1@data$NAME_1
- center.df <- as.data.frame(coordinates(smap1))
- names(center.df) <- c("long", "lati")
- fin.df <- data.frame(id = idList, center.df)
- ggplot()+
- theme_void()+
- geom_polygon(data = smap1_df, aes(x = long, y = lat, group = group, fill = id), color = "white") +
- coord_map()+
- geom_text(aes(label = id, x = long, y = lati), data = fin.df)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement