R2-07-第二期 -地理绘图

Bamboo 2018-01-02 19:27:02 阅读: 1182

 library(maptools)

> china_map<-readShapePoly("bou2_4p.shp")

Warning message:

use rgdal::readOGR or sf::st_read 

> x<-china_map@data

> xs<-data.frame(x,id=seq(0:924)-1)

> library(ggplot2)

> china_map1<-fortify(china_map)

Regions defined for each Polygons

> library(plyr)

> china_mapdata<-join(china_map1, xs, type = "full") 

Joining by: id

> data<-read.csv("R2-9.csv")

> pop<-data.frame(NAME,pop)

> china_pop<-join(china_mapdata, pop, type = "full")

Joining by: NAME

> ggplot(china_pop, aes(x = long, y = lat, group = group,fill=pop))+

+   geom_polygon(aes())+

+   scale_fill_gradient(low="white",high="red")+

+   geom_path(colour = "grey40")+

+   ggtitle("R2-07")

1.jpg


 

> getwd()

[1] "C:/Users/Administrator/Desktop/R语言"

> library(maptools)

> china_map<-readShapePoly("bou2_4p.shp")

Warning message:

use rgdal::readOGR or sf::st_read 

> x<-china_map@data

> xs<-data.frame(x,id=seq(0:924)-1)

> library(ggplot2)

> china_map1<-fortify(china_map)

Regions defined for each Polygons

> library(plyr)

> china_mapdata<-join(china_map1, xs, type = "full") 

Joining by: id

> Hunan<-subset(china_mapdata,NAME=="湖南省")

>ggplot(Hunan, aes(x = long, y = lat, group = group,fill=NAME))+

+   geom_polygon(fill="pink" )+

+   geom_path(colour = "grey40")+geom_point(x=112.58,y=28.11,fill="black")+

+     annotate("text",x=112.7,y=28,label="长沙") +annotate("text",x=111,y=29,label="湖南省",size=8,colour="blue")+ggtitle("R2-07")


2.jpg

 
邀请讨论

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
{{item.nick_name}} 受邀请回答 {{item.create_time}}
{{item.refer_comment.nick_name}} {{item.refer_comment.create_time}}

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
切换到完整回复 发送回复
赞({{item.count_zan}}) 踩({{item.count_cai}}) 删除 回复 关闭
科研狗©2015-2024 科研好助手,京ICP备20005780号-1 建议意见

服务热线

178 0020 3020

微信服务号