根据某电信运行商基站清单数据,通过经纬度信息画出这些点在北京的分布,R,数据集就不给出了,最后代码中给出了处理后真正作图的样本数据
############################################## library(ggmap) library(mapproj) library(DBI) library(RMySQL) con=dbConnect(MySQL(),user='root',password='123',dbname='cmcc',host='localhost') zhongguancun=dbGetQuery(con,'select cell_name,longtitude,latitude from 8_15_table_9 where DEPT_NAME="中关村片区1" or DEPT_NAME="中关村片区2"')#从数据库获取中关村的基站经纬度 #jingweidu=read.csv('./cmcc_doc/基站清单1.txt',header=T,colClasses=c('NULL','factor',rep(list('NULL'),4),'numeric','numeric',rep(list('NULL'),21))) #classes=sapply(jingweidu,class) names(jingweidu)=c('name','longitude','latitude') #google给我中关村的公路地图数据吧 bjmap <- qmap('zhongguancun', zoom = 12, maptype = 'roadmap') bjmap <- bjmap + geom_point(data = zhongguancun, aes(x = longtitude, y = latitude), size = 5)+ geom_path(aes(x = longtitude, y = latitude), colour = 'red', size = 1.5,data = zhongguancun[1:5,], lineend = 'round')#画出数据中前五个地点之间的线段图 bjmap
作图数据样本格式:也是红线的起始点
cell_name longtitudelatitude
1 北大资源东楼1 116.3073 39.98543