我正在尝试为我的数据中给定的一组纬度和经度提取海拔数据。我试图查找一些较旧的答案(从 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 版本,不会下载 elevtr 包。
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”
###编辑:什么有效?
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)