library(REmap)
knitr::opts_chunk$set(echo = FALSE,cache = F)

R Markdown

This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

Slide with Bullets

http://lbs.amap.com/api/webservice/summary/

http://lbsyun.baidu.com/index.php?title=webapi.

Slide with R Output

library(bamapr)
data(fzbus)


bus$name=paste(bus$name,bus$id,sep="")
pointData=data.frame(name=bus[,"name"],color="#7CCD7C")
geodata=bus[,c("lon_bd","lat_bd","name")]
# geodata$lon=as.numeric(geodata$lon)
# geodata$lat=as.numeric(geodata$lat)
#转换成百度地图
lonlat=data.frame(geoconv(geodata[c(1:2)]))
colnames(lonlat)=c("lon_bd","lat_bd")
bus=cbind(bus,lonlat)
remap.init()
p=remapB(center = get_city_coord("福州"),
       zoom = 14,
       title = "福州公交站分布图",
       color = "googlelite",
       markPointData = pointData,
       markPointTheme = markPointControl(symbol = 'pin',
                                         symbolSize = 5,
                                         effect = F),
       geoData = geodata)
knitrREmap(p,local = F,height = "100%")
cat("福州全市(含五区八县)共",nrow(bus),"个公交车站\n")
route=unlist(strsplit(bus$address,split = "[;/\\.]"))
route=route[!duplicated(route)]
route=route[-38]
route_dy=route[-grep(pattern = "停运",x = route)]
cat("福州全市(含五区八县)共",length(route_dy),"个公交线路\n")

Slide with Plot

cat("公交路线及其站点查询\n")
road="1路"
x=getBusRoute(keywords=road)
head(x)
ll=getBusRoute(keywords=road,getcoord=T,gettime=T)
cat("公交路线早晚班时间\n")
ll[[2]]
cat("公交路线路径地图\n")
y=ll[[3]]
y[1,1]=gsub(pattern = "\\]",replacement = "",x = y[1,1])
mtx=matrix(as.numeric(unlist(strsplit(y[1,1],split = ","))),ncol=2,byrow=T)
#转换为百度地图坐标
mtx=geoconv(geocode = mtx,from = 3, to = 5)
geodata=mtx2geoData(mtx,name = road)
#geodata先经度后维度
#col=rgb(red =252,green = 249,blue =0.5 )
linedata=mtx2lineData(mtx = mtx,name = road,color ="#00F5FF")

remap.init()
p=remapB(center = get_city_coord("福州"),
       zoom = 14,
       title = paste("福州",road,"公交",sep=""),
       color = "googlelite",

       markLineData =linedata,
       markLineTheme = markLineControl(smoothness = 0,lineWidth=3,
                                       effect = F,lineType = "solid",
                                       symbolSize = c(0,0)),
       geoData = geodata[,c(2,1,3)])
knitrREmap(p,local = F,height = "100%")


daigazi/bamapr documentation built on May 14, 2019, 3:28 p.m.