我想使用getData()函数下载5分钟高度的worldclim并计算表面积。为此:
library(raster)
#Download worldclim 5 minutes altitude for whole world
elevation_world <- getData('worldclim', var='alt', res=5, lon=180, lat=85)
Error in file(con, "r") : cannot open the connection
In addition: Warning messages:
1: In utils::unzip(zipfile, exdir = dirname(zipfile)) :
error 1 in extracting from zip file
2: In file(con, "r") :
cannot open file 'C:/Users/fores/Documents/wc5/alt.hdr': No such file or directory
elevation_world <- getData('worldclim', var='alt', res=5, lon=-180, lat=-85)
Error in file(con, "r") : cannot open the connection
In addition: Warning messages:
1: In utils::unzip(zipfile, exdir = dirname(zipfile)) :
error 1 in extracting from zip file
2: In file(con, "r") :
cannot open file 'C:/Users/fores/Documents/wc5/alt.hdr': No such file or directory
为什么不能用我的经/长选择呢?
第二,我也很喜欢用height_world对象计算地球表面积:
grids <- as(elevation_world, "SpatialGridDataFrame")
proj4string(grids) <- CRS(wgs.84)
areaSpatialGrid(grids)
我希望以km2为单位的输出如下:
[1]510072000
有什么想法吗?在此先感谢!
答案 0 :(得分:1)
您可以这样做:
library(raster)
r <- getData('worldclim', var='alt', res=5)
a <- area(r)
b <- mask(a, r)
cellStats(b, sum)
#[1] 137881247
但是请注意,这不包括南极洲。相反,您可以
第一个问题:这些论点不适用。