一 前期準備
1 參考網(wǎng)址 https://rdrr.io/cran/rgbif/man/elevation.html
2 Rverson 4.0.2
3 提前注冊??http://www.geonames.org/login,得到用戶名XXX
二 安裝需要的包
install.packages(c("here","sp","rgbif"))
library(rgbif)
library(here)
library(sp)
三 讀取經(jīng)緯度數(shù)據(jù)
geo=read.csv("Farjon.csv",header=T)
geo=subset(geo,!is.na(Latitude))
head(geo)
#? ?taxon Latitude Longitude Elevation
#1 A_alba 50.35000 16.883333? ? ? ? ?0
# 2 A_alba 49.13333 22.150000? ? ? ? ?0
?#3 A_alba 50.88333 18.433333? ? ? ? ?0
四 提取海拔
options(geonamesUsername = "XXX")
file.edit(here::here(".Rprofile"))
user <- "XXX" #需注冊,見前期準備
lats <- geo$Latitude
lons <- geo$Longitude
abie_ele=elevation(latitude = lats, longitude = lons, elevation_model = "srtm1",username = user)? #srtm1=30m*30m,最高分辨率怔软。