如何在给定经纬度的情况下提取海拔高度?
How to extract altitude above sea level given latitude and longitude?
我正在尝试为我的数据中给定的一组经纬度提取高度数据。我试图查找一些较旧的答案(9 到 10 年前)..但是许多方法已经过时或功能不起作用。有什么新鲜的建议吗?
lat <- c(45.08323,40.08323)
long <- c(-82.46797,-81.46797)
df <- data.frame(lat, long)
我尝试了以下建议:
- Using the geonames package, and get the value from the srtm3 digital elevation model
我 运行 进入错误说:Error in url(url, open = "r") : cannot open the connection to 'http://api.geonames.org/srtm3JSON?lat=NA&lng=NA&
- 我尝试按照链接答案中的建议使用 googleway and 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.
当我尝试安装所需的包时:
"package ‘libudunits2’ is not available for this version of 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)
这得到了第二点,但没有得到第一点。
library(elevatr)
library(rgdal)
lat <- c(45.08323,40.08323)
long <- c(-82.46797,-81.46797)
df <- data.frame(long, lat)
get_elev_point(df, prj="EPSG:4326")
# Note: Elevation units are in &units=Meters
# Note:. The coordinate reference system is:
# GEOGCRS["WGS 84 (with axis order normalized for visualization)",
# DATUM["World Geodetic System 1984",
# ELLIPSOID["WGS 84",6378137,298.257223563,
# LENGTHUNIT["metre",1]]],
# PRIMEM["Greenwich",0,
# ANGLEUNIT["degree",0.0174532925199433]],
# CS[ellipsoidal,2],
# AXIS["geodetic longitude (Lon)",east,
# ORDER[1],
# ANGLEUNIT["degree",0.0174532925199433,
# ID["EPSG",9122]]],
# AXIS["geodetic latitude (Lat)",north,
# ORDER[2],
# ANGLEUNIT["degree",0.0174532925199433,
# ID["EPSG",9122]]]]
# coordinates elevation elev_units
# 1 (-82.46797, 45.08323) NA meters
# 2 (-81.46797, 40.08323) 271.82 meters
需要在 https://www.geonames.org/manageaccount
上创建用户名并启用网络服务
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)
我正在尝试为我的数据中给定的一组经纬度提取高度数据。我试图查找一些较旧的答案(9 到 10 年前)..但是许多方法已经过时或功能不起作用。有什么新鲜的建议吗?
lat <- c(45.08323,40.08323)
long <- c(-82.46797,-81.46797)
df <- data.frame(lat, long)
我尝试了以下建议:
- Using the geonames package, and get the value from the srtm3 digital elevation model
我 运行 进入错误说:Error in url(url, open = "r") : cannot open the connection to 'http://api.geonames.org/srtm3JSON?lat=NA&lng=NA&
- 我尝试按照链接答案中的建议使用 googleway and 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.
当我尝试安装所需的包时:
"package ‘libudunits2’ is not available for this version of 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)
这得到了第二点,但没有得到第一点。
library(elevatr)
library(rgdal)
lat <- c(45.08323,40.08323)
long <- c(-82.46797,-81.46797)
df <- data.frame(long, lat)
get_elev_point(df, prj="EPSG:4326")
# Note: Elevation units are in &units=Meters
# Note:. The coordinate reference system is:
# GEOGCRS["WGS 84 (with axis order normalized for visualization)",
# DATUM["World Geodetic System 1984",
# ELLIPSOID["WGS 84",6378137,298.257223563,
# LENGTHUNIT["metre",1]]],
# PRIMEM["Greenwich",0,
# ANGLEUNIT["degree",0.0174532925199433]],
# CS[ellipsoidal,2],
# AXIS["geodetic longitude (Lon)",east,
# ORDER[1],
# ANGLEUNIT["degree",0.0174532925199433,
# ID["EPSG",9122]]],
# AXIS["geodetic latitude (Lat)",north,
# ORDER[2],
# ANGLEUNIT["degree",0.0174532925199433,
# ID["EPSG",9122]]]]
# coordinates elevation elev_units
# 1 (-82.46797, 45.08323) NA meters
# 2 (-81.46797, 40.08323) 271.82 meters
需要在 https://www.geonames.org/manageaccount
上创建用户名并启用网络服务 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)