Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. library(ggplot2)
  2. library(rgdal)
  3. library(sp)
  4.  
  5. smap1 <- readOGR("C:/Users/idan.benaun/Downloads/NGA_adm_shp/NGA_adm1.shp")
  6. smap1_df <- fortify(smap1, region = "NAME_1")
  7. idList <- smap1@data$NAME_1
  8. center.df <- as.data.frame(coordinates(smap1))
  9. names(center.df) <- c("long", "lati")
  10. fin.df <- data.frame(id = idList, center.df)
  11.  
  12. ggplot()+
  13. theme_void()+
  14. geom_polygon(data = smap1_df, aes(x = long, y = lat, group = group, fill = id), color = "white") +
  15. coord_map()+
  16. geom_text(aes(label = id, x = long, y = lati), data = fin.df)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement