【发布时间】:2021-09-15 08:23:37
【问题描述】:
我正在尝试为我的数据中给定的一组纬度和经度提取海拔数据。我试图查找一些较旧的答案(从 9 到 10 年前)..但是许多方法已经过时或功能不起作用。有什么新鲜的建议吗?
lat <- c(45.08323,40.08323)
long <- c(-82.46797,-81.46797)
df <- data.frame(lat, long)
我尝试了以下建议:
我遇到如下错误:Error in url(url, open = "r") : cannot open the connection to 'http://api.geonames.org/srtm3JSON?lat=NA&lng=NA&
- 我尝试按照链接答案中的建议使用 googleway 和 elevatr pacakages
对于最新的 R > 4.0 版本,不会下载 elevatr 包。
I get an error that says Configuration failed because libudunits2.so was not found. Try installing:
* deb: libudunits2-dev (Debian, Ubuntu, ...)
* rpm: udunits2-devel (Fedora, EPEL, ...)
* brew: udunits (OSX)
If udunits2 is already installed in a non-standard location, use:
--configure-args='--with-udunits2-lib=/usr/local/lib'
if the library was not found, and/or:
--configure-args='--with-udunits2-include=/usr/include/udunits2'
if the header was not found, replacing paths with appropriate values.
You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.
当我尝试安装所需的包时:
“包‘libudunits2’不适用于这个版本的R”
###EDIT:什么有效?
library(geonames)
readLines(url("http://api.geonames.org/",open="r"))
options(geonamesUsername= "MyUsername") #Note you have to create a username one the website AND enable webservices on your geonames user account at https://www.geonames.org/manageaccount.
GNsrtm3(54.481084,-3.220625)
【问题讨论】:
-
@user20650 都没有用。对于第一个,它一直说连接错误,第二个在最新的 R 版本中无法加载包
-
好的。如果您添加了所有您尝试过但对您的问题不起作用的东西,以节省您在建议上浪费时间,这可能会有所帮助
-
第二个错误是因为你需要系统库。所以试试
apt install libudunits2-dev(来自sudo)——或者任何相关的——然后尝试重新安装 -
libudunits2是一个 system 包,而不是 R 包。 Linux (deb,rpm) 或 MacOS (brew) 的错误消息中给出了安装说明
标签: r google-maps latitude-longitude google-latitude google-elevation-api