easychart / china_map_sourcedata Goto Github PK
View Code? Open in Web Editor NEW代码运行数据
License: Apache License 2.0
代码运行数据
License: Apache License 2.0
setwd("/Users/mashengwei/Desktop/scripts/Original_Data-master/")
library(rgdal)
library(ggplot2)
library(dplyr)
library(RColorBrewer)
dataProjected <- readOGR("./bou2_4m/bou2_4p.shp")
dataProjected@data$id <- rownames(dataProjected@data)
watershedPoints <- fortify(dataProjected)
df_China <- full_join(watershedPoints, dataProjected@data, by = "id")
df_China$class<-rep("Mainland",nrow(df_China))
mydata <- read.csv("Province_Data.csv", as.is=T)
#mydata为33 X 3的表格数据,列名分别为:NAME,province,Value
#.csv数据下载:https://github.com/EasyChart/Original_Data
df_China<-full_join(df_China,mydata,type="full")
Width<-9
Height<-9
long_Start<-124
lat_Start<-16
df_Nanhai<-df_China[df_China$long>106.55 & df_China$long<123.58,]
df_Nanhai<-df_Nanhai[df_Nanhai$lat>4.61 & df_Nanhai$lat<25.45,]
min_long<-min(df_Nanhai$long, na.rm = TRUE)
min_lat<-min(df_Nanhai$lat, na.rm = TRUE)
max_long<-max(df_Nanhai$long, na.rm = TRUE)
max_lat<-max(df_Nanhai$lat, na.rm = TRUE)
df_Nanhai$long<-(df_Nanhai$long-min_long)/(max_long-min_long)*Width+long_Start
df_Nanhai$lat<-(df_Nanhai$lat-min_lat)/(max_lat-min_lat)*Height+lat_Start
df_Nanhai$class<-rep("NanHai",nrow(df_Nanhai))
df_China<-rbind(df_China,df_Nanhai)
#---------------------df_NanHaiLine:Nanhai Line-----------------------------------
df_NanHaiLine <- read.csv("**南海九段线.csv")
colnames(df_NanHaiLine)<-c("long","lat","ID")
df_NanHaiLine$long<-(df_NanHaiLine$long-min_long)/(max_long-min_long)*Width+long_Start
df_NanHaiLine$lat<-(df_NanHaiLine$lat-min_lat)/(max_lat-min_lat)*Height+lat_Start
#-----------------------**省份分级统计地图-----------------------
ggplot()+
geom_polygon(data=df_China, aes(x=long, y=lat, group=interaction(class,group),fill=Value),colour="black",size=0.25)+
#**地图,包括**主体部分和长方形方块内的南海诸岛数据
geom_rect(aes(xmin=long_Start, xmax=long_Start+Width+0.3, ymin=lat_Start-0.3, ymax=lat_Start+Height),fill=NA, colour="black",size=0.25)+
#绘制长方形方框
geom_line(data=df_NanHaiLine, aes(x=long, y=lat, group=ID), colour="black", size=1)+
#绘制长方形方框内的**南海八段线
scale_fill_gradientn(colours = colorRampPalette(rev(brewer.pal(11,'Spectral')))(32))+
coord_cartesian()+
ylim(15,55)+
theme(
legend.position=c(0.15,0.2),
legend.background = element_blank()
)
not support Chinese?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.