学习笔记:从0开始学习大数据-23. R语言recharts,REMap案例

以下学习的三个例子均copy自网络,调试运行后的代码和运行结果复制如下,以备后用。

一、地图块

library(ggplot2)
library(baidumap)
library(ggmap)
options(baidumap.key = 'XXX')
q <- getBaiduMap('广州白云山', width=600, height=600, zoom=18, scale = 2, messaging=FALSE)
ggmap(q) 

二、热力图

library(REmap)
options(remap.js.web=T)
data<- read.csv(file="/home/linbin/文档/R/cityvaluetop10.csv",header=T)
theme1 <- get_theme(theme = "none",
                    lineColor = "white",
                    backgroundColor = "white", 
                    titleColor = "#fff",
                    borderColor = "blue", 
                    regionColor = "grey",
                    labelShow = T, 
                    pointShow = F, 
                    pointColor = "gold")
remapH(data,
       maptype = 'china',
       theme = theme1,
       blurSize = 70,
       color = "red",
       minAlpha = 10,
       opacity = 1,)

cityvaluetop10.csv 文件数据格式

lon,lat,prob
114.394818,23.408004,0.85
110.50664,28.695864,0.8
112.920664,26.695864,0.8
112.720664,26.695864,0.8
113.487804,34.157184,0.75
...

三、迁移图

library(ggplot2)
library(baidumap)
library(REmap)
library(ggmap)
options(baidumap.key = 'XXX')
options(remap.ak = "XXX")
#get_city_coord("天津")
#city_list <- c("beijing","tianjin","hefei","suzhou","chongqing")
#get_geo_position(city_list)
destination<- c("beijing","tianjin","nanjing","hefei","chengdu")    #终点
origin<- rep("guangzhou",length(destination)) 
map_data<- data.frame(origin,destination)
head(map_data)
map_out<-remap(mapdata=map_data,   #流向地图的数据源(依次为起点、终点两列)
               title="我是标题",         #设置主标题
               subtitle="我是副标题",    #设置副标题
               theme =get_theme(theme="Sky")) #设置主题(默认主题一共有三套:“Dark”,“Bright,”Sky“)
plot(map_out)

猜你喜欢

转载自blog.csdn.net/oLinBSoft/article/details/84865496