Created by Chiffon郎大为
Supstat. Inc 数据科学家
目的:
相关工具
maps
ggmap
choroplethr
leaflet
googleVis
RgoogleMaps
, mapdata
, mapproj
, baidumap
,...maps
library(maps)
library(mapdata)
data("chinaMapEnv")
map('china')
choroplethr
library(choroplethr)
library(choroplethrMaps)
data(df_pop_country)
country_choropleth(df_pop_country,
title = "2012 Population Estimates",
legend = "Population",
num_colors = 1,
zoom = c("china", "japan",
"north korea","south korea"))
ggmap
devtools::install.github("badbye/baidumap")
library(baidumap)
p <- getBaiduMap('南昌') # the same
ggmap(p)+ geom_point(aes(x=115.9,y=28.7),size = 3,color='red')
leaflet
recharts
library(leaflet)
m = leaflet() %>% addTiles()
m = m %>% setView(115.86453, 28.68767, zoom = 17)
devtools::install_github('lchiffon/REmap')
library(REmap)
省份 | GDP(亿元) |
---|---|
北京 | 10578.28 |
天津 | 7884.04 |
河北 | 13798.13 |
上海 | 11887 |
... | ... |
数据来源: 中国统计年鉴2015年第二季度GDP
library(REmap)
GDP = read.csv("data/GDP.csv",encoding = "UTF-8")
remapC(GDP,
color = c("red","yellow"),
title = "2015年第二季度中国各省份GDP(亿元)",
subtitle = "数据来源中国统计年鉴")
city | space | population |
---|---|---|
南昌市 | 7402.36 | 504.3 |
九江市 | 18823 | 485 |
上饶市 | 22791 | 740 |
抚州市 | 18817 | 400 |
... | ... | ... |
数据来源: http://baike.baidu.com
popu = read.csv("data/jiangxi.csv",encoding = "UTF-8")
plotdata = data.frame(city = popu$city,
density = popu$population/popu$space*1e4)
remapC(data = plotdata,maptype = "江西",
title = "江西人口密度(人/平方公里)")
出发点 | 到达点 |
---|---|
北京 | 上海 |
北京 | 广州 |
北京 | 大连 |
北京 | 南宁 |
... | ... |
remap(demoC,theme = get_theme("Bright"))
remapB(markLineData = demoC,
markPointData = demoC[,2])
# remapB(markLineData = demoC,
# markPointData = demoC[,2],color = "Blue")
## 获取线路
library(baidumap)
df = getRoute('南昌西站', '江西财经大学北区',region="南昌")
## 准备数据
df$label = paste("Point",1:dim(df)[1])
markLinedata = data.frame(origin = df$label[-dim(df)[1]],
destination = df$label[-1])
## 绘制地图
remapB(center = get_city_coord("南昌"),
zoom = 13,
markLineData = markLinedata,geoData = df,
markLineTheme = markLineControl(smoothness = 0,
effect = T,
symbolSize = c(0,0)))
## 获取数据
barbeque = getPlace('烧烤', '南昌')
## 准备数据
barbeque$tooltip = paste(barbeque$name,
barbeque$address,
barbeque$telephone,sep = "<br/>")
geodata = data.frame(barbeque$lon,
barbeque$lat,
barbeque$name)
## 绘制数据
remapB(center = get_city_coord("江西财经大学北区"),
zoom = 15,
markPointData = barbeque,
geoData = geodata,
markPointTheme = markPointControl(effect = F,symbol = "pin",
symbolSize = 7,
color="red"),
title="南昌烧烤分布")
place | name | time |
---|---|---|
西安 | 2015数据与价值欧亚论坛暨R会议西安分论坛 | 2015年4月18日 |
广州 | 中国R语言(广州)会议-暨华南地区数据科学会议 | 2015年5月23-24日 |
北京 | 第八届中国R语言会议(北京) | 2015年6月6-7日 |
... | ... | ... |
数据来源: http://cos.name
## 读取数据
rCon = read.csv("data/R-con.csv",encoding = "UTF-8")
## 准备数据
rCon$pic = paste0("<img src=",rCon$pic," width=300px />")
plotdata = data.frame(place = rCon$place,
symbol = "image://./pic/cos.png",
tooltip = paste(rCon$name,rCon$time,rCon$pic,sep = "<br/>"))
## 绘制地图
remapC(data = chinaIphone,
color = c("white","white"),
markPointData = plotdata,
markPointTheme = markPointControl(effect = F,
symbolSize = 30),
title = "2015中国R语言会议"
)
cityvec = c("上海",
"广州","大连","南宁","南昌","拉萨","长春","包头",
"重庆","武汉","北京","洛阳","台北","乌鲁木齐","沈阳",
"西安","成都","合肥","长沙","济南","福州","兰州")
weather = sapply(cityvec,get_weather_str)
plotdata = data.frame(cityvec,
tooltip=paste0(cityvec,weather[1,]),
symbol = weather[2,])
remapB(markPointData = plotdata,
markPointTheme = markPointControl(symbolSize = 25,
effect = F),
color = "Blue",
title = "未来天气预报",
subtitle = "by REmap, Chiffon")