Thursday, March 23, 2017

R: Map Pakistan

Pakistan <- data.frame(map("world", "Pakistan", plot=FALSE)[c("x","y")])
or



Link

windows()
map("world","Pakistan")
map.cities(country="Pakistan")
or

Pakcities<-world.cities[which(world.cities$country.etc="Pakistan"),]
rest is for displaying Pakistan map with cities
--------------------------------------
 stat1<-map_data("world",country = "Pakistan")
stat1<-stat1[which(stat1$region =="Pakistan"),]
a4<-Pakcities[4]
a5<-Pakcities[5]
aaa<-data.frame(a4,a5)
gg <- ggplot(data=stat1, aes(x=long,y=lat))
gg <- gg + coord_map("mercator")
gg<- gg + geom_path(aes(group=group),colour="gray80")
gg <- gg + geom_point(data=aaa, aes(long, lat), 
                      colour="#000099", alpha=1/40, size=1)
print(gg)

No comments:

Post a Comment