REmap入门示例
请问在用remap函数的时候,出现警告:Warning message:
In get_geo_position(city_vec) : 北京 not found.广州 not found.
In get_geo_position(city_vec) : 北京 not found.广州 not found.
[未知用户] Sys.setlocale("LC_CTYPE", "English_United Kingdom.1252")
参考:https://github.com/Lchiffon/REmap/issues/4
参考:https://github.com/Lchiffon/REmap/issues/4
> install_github('lchiffon/REmap')
Downloading GitHub repo lchiffon/REmap@master
from URL https://api.github.com/repos/lchiffon/REmap/zipball/master
Error in curl::curl_fetch_memory(url, handle = handle) :
Peer certificate cannot be authenticated with given CA certificates
Downloading GitHub repo lchiffon/REmap@master
from URL https://api.github.com/repos/lchiffon/REmap/zipball/master
Error in curl::curl_fetch_memory(url, handle = handle) :
Peer certificate cannot be authenticated with given CA certificates
非常棒的工作!我最近在使用baidumap的时候遇到一个问题:分别用ggmap和baidumap获取同一位置(如中国矿业大学北京),然后将他们获取的位置标在leaflet地图上,发现差别好大呀!Why?是baidumap不准确吗?
下面是我的代码
library(leaflet)
library(baidumap)
## getcoordinate return vector
loc<-getCoordinate('中国矿业大学(北京)', formatted = T) # character
library(ggmap)
## geocode return dataframe
ggloc<-geocode("China University of Mining and Technology,Beijing")
## plot
CUMTB %
addTiles() %>% # Add default OpenStreetMap map tiles
addMarkers(lng=loc[1], lat=loc[2],
popup="China University of Mining and Technology,Beijing")
CUMTB # Print
ggCUMTB %
addTiles() %>% # Add default OpenStreetMap map tiles
addMarkers(lng=ggloc$lon, lat=ggloc$lat,
popup="China University of Mining and Technology,Beijing")
ggCUMTB # Print
下面是我的代码
library(leaflet)
library(baidumap)
## getcoordinate return vector
loc<-getCoordinate('中国矿业大学(北京)', formatted = T) # character
library(ggmap)
## geocode return dataframe
ggloc<-geocode("China University of Mining and Technology,Beijing")
## plot
CUMTB %
addTiles() %>% # Add default OpenStreetMap map tiles
addMarkers(lng=loc[1], lat=loc[2],
popup="China University of Mining and Technology,Beijing")
CUMTB # Print
ggCUMTB %
addTiles() %>% # Add default OpenStreetMap map tiles
addMarkers(lng=ggloc$lon, lat=ggloc$lat,
popup="China University of Mining and Technology,Beijing")
ggCUMTB # Print
[未知用户] 这个是devtools的问题,试试httr::set_config( httr::config( ssl_verifypeer = 0L ) )能处理不..
[未知用户] 这个是因为不同源的经纬度需要相互转化,比如百度和谷歌的经纬度,相互会有几百米的偏移..
百度有提供一些转化的API接口..
http://lbsyun.baidu.com/index.php?title=webapi/guide/changeposition
百度有提供一些转化的API接口..
http://lbsyun.baidu.com/index.php?title=webapi/guide/changeposition
[未知用户] 谢谢,明白了!逛了一圈,百度不够open啊!需要ak,就得“卖身”!!
> library(devtools)
> install_github('lchiffon/REmap')
Downloading GitHub repo lchiffon/REmap@master
from URL https://api.github.com/repos/lchiffon/REmap/zipball/master
Installing REmap
"D:/R-3.2.5/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL \
"C:/Users/Administrator/AppData/Local/Temp/RtmpSwi1xZ/devtools13086ee688e/Lchiffon-REmap-a05489f" \
--library="D:/R-3.2.5/library" --install-tests
* installing *source* package 'REmap' ...
** R
** data
*** moving datasets to lazyload DB
** demo
** inst
** preparing package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called 'Rcpp'
ERROR: lazy loading failed for package 'REmap'
* removing 'D:/R-3.2.5/library/REmap'
错误: Command failed (1)
安装不了啊急
> install_github('lchiffon/REmap')
Downloading GitHub repo lchiffon/REmap@master
from URL https://api.github.com/repos/lchiffon/REmap/zipball/master
Installing REmap
"D:/R-3.2.5/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL \
"C:/Users/Administrator/AppData/Local/Temp/RtmpSwi1xZ/devtools13086ee688e/Lchiffon-REmap-a05489f" \
--library="D:/R-3.2.5/library" --install-tests
* installing *source* package 'REmap' ...
** R
** data
*** moving datasets to lazyload DB
** demo
** inst
** preparing package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called 'Rcpp'
ERROR: lazy loading failed for package 'REmap'
* removing 'D:/R-3.2.5/library/REmap'
错误: Command failed (1)
安装不了啊急
[未知用户] 里面提到: there is no package called 'Rcpp'
所以你需要
install.packages("Rcpp")
所以你需要
install.packages("Rcpp")
install_github('lchiffon/REmap')
Downloading GitHub repo lchiffon/REmap@master
from URL https://api.github.com/repos/lchiffon/REmap/zipball/master
Installing REmap
"f:/Program Files/R/R-3.2.2/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD \
INSTALL "C:/Users/liweitang/AppData/Local/Temp/RtmpigW5L3/devtools1ee4393a167a/Lchiffon-REmap-a05489f" \
--library="F:/Program Files/R/R-3.2.2/my_library" --install-tests
'f:\Program' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
Error: Command failed (1)
Downloading GitHub repo lchiffon/REmap@master
from URL https://api.github.com/repos/lchiffon/REmap/zipball/master
Installing REmap
"f:/Program Files/R/R-3.2.2/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD \
INSTALL "C:/Users/liweitang/AppData/Local/Temp/RtmpigW5L3/devtools1ee4393a167a/Lchiffon-REmap-a05489f" \
--library="F:/Program Files/R/R-3.2.2/my_library" --install-tests
'f:\Program' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
Error: Command failed (1)
[未知用户] 解决了,谢谢!
21 天 后
Downloading GitHub repo lchiffon/REmap@master
from URL https://api.github.com/repos/lchiffon/REmap/zipball/master
Installing REmap
Installing 1 package: XML
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/XML_3.98-1.4.zip'
Content type 'application/zip' length 4290726 bytes (4.1 MB)
downloaded 144 KB
Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
cannot open the connection
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 147456 != reported length 4290726
2: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
3: In read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such file or directory'
from URL https://api.github.com/repos/lchiffon/REmap/zipball/master
Installing REmap
Installing 1 package: XML
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/XML_3.98-1.4.zip'
Content type 'application/zip' length 4290726 bytes (4.1 MB)
downloaded 144 KB
Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
cannot open the connection
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 147456 != reported length 4290726
2: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
3: In read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such file or directory'
Error in curl::curl_fetch_disk(url, x$path, handle = handle) :
Timeout was reached
Timeout was reached
8 天 后
[未知用户] 好像是你的XML包安装有问题
17 天 后
```{r}
library(REmap)
set.seed(125)
origin = rep("北京",10)
destination = c('上海','广州','大连','南宁','南昌',
'拉萨','长春','包头','重庆','常州')
dat = data.frame(origin,destination)
out = remap(dat,title = "REmap实例数据",subtitle = "theme:Dark")
plot(out)
```
老师,这段代码直接运行可以做出图,但是再rmarkdown文档里knit HTML时却会出现
library(REmap)
set.seed(125)
origin = rep("北京",10)
destination = c('上海','广州','大连','南宁','南昌',
'拉萨','长春','包头','重庆','常州')
dat = data.frame(origin,destination)
out = remap(dat,title = "REmap实例数据",subtitle = "theme:Dark")
## Warning in get_geo_position(city_vec): 北京 not found.上海 not found.广州
## not found.南宁 not found.南昌 not found.拉萨 not found.长春 not found.包头
## not found.重庆 not found.常州 not found.
plot(out)
## Save img as: C:\Users\YAOCHA~1\AppData\Local\Temp\RtmpEDZIei/ID_20160819145217_243.html
library(REmap)
set.seed(125)
origin = rep("北京",10)
destination = c('上海','广州','大连','南宁','南昌',
'拉萨','长春','包头','重庆','常州')
dat = data.frame(origin,destination)
out = remap(dat,title = "REmap实例数据",subtitle = "theme:Dark")
plot(out)
```
老师,这段代码直接运行可以做出图,但是再rmarkdown文档里knit HTML时却会出现
library(REmap)
set.seed(125)
origin = rep("北京",10)
destination = c('上海','广州','大连','南宁','南昌',
'拉萨','长春','包头','重庆','常州')
dat = data.frame(origin,destination)
out = remap(dat,title = "REmap实例数据",subtitle = "theme:Dark")
## Warning in get_geo_position(city_vec): 北京 not found.上海 not found.广州
## not found.南宁 not found.南昌 not found.拉萨 not found.长春 not found.包头
## not found.重庆 not found.常州 not found.
plot(out)
## Save img as: C:\Users\YAOCHA~1\AppData\Local\Temp\RtmpEDZIei/ID_20160819145217_243.html
[未知用户] 我也出现这种情况了,估计是编码问题,我试着把中文转成拼音就可以了,有3个无法识别改为 nanning --> nanzningz;nanchang --> nachang 常州是怎么也识别不了,看你有什么别的方法,我试过UTF-8,GBk等格式都不行
6 天 后
[未知用户] 我也遇到了这个问题,请问怎么解决啊?
2 个月 后
> install_github("lchiffon/REmap")
Downloading GitHub repo lchiffon/REmap@master
from URL https://api.github.com/repos/lchiffon/REmap/zipball/master
Installing REmap
"B:/R Programming/bin/x64/R" --no-site-file --no-environ --no-save \
--no-restore --quiet CMD INSTALL "C:/Users/Zoe \
Cheng/AppData/Local/Temp/RtmpIpLzT0/devtools50606a5a6aa1/Lchiffon-REmap-faa8a59" \
--library="B:/R Programming/library" --install-tests
'B:\R' is not recognized as an internal or external command,
operable program or batch file.
Error: Command failed (1)
如何解决?
Downloading GitHub repo lchiffon/REmap@master
from URL https://api.github.com/repos/lchiffon/REmap/zipball/master
Installing REmap
"B:/R Programming/bin/x64/R" --no-site-file --no-environ --no-save \
--no-restore --quiet CMD INSTALL "C:/Users/Zoe \
Cheng/AppData/Local/Temp/RtmpIpLzT0/devtools50606a5a6aa1/Lchiffon-REmap-faa8a59" \
--library="B:/R Programming/library" --install-tests
'B:\R' is not recognized as an internal or external command,
operable program or batch file.
Error: Command failed (1)
如何解决?
1 个月 后
[未知用户] 你的工作目录需要在C盘