r - 为什么在 r 中重新采样栅格时会得到 NA 值
问题描述
我有两个不同程度的栅格,但是当我在 R 中使用 resample 时,输出是一个空白栅格......我该如何解决这个问题?请参阅下面使用的一些代码....重新采样的栅格出现在值中带有 NA....
show(alt)
class : RasterLayer
dimensions : 1800, 4320, 7776000 (nrow, ncol, ncell)
resolution : 0.08333334, 0.08333334 (x, y)
extent : -180, 180, -60, 90.00001 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs
data source : C:\Users\Mafalda\Documents\bio_5m_esri\alt5.asc
names : alt5
values : -2147483648, 2147483647 (min, max)
show(hfp)
class : RasterLayer
dimensions : 16382, 36081, 591078942 (nrow, ncol, ncell)
resolution : 1000, 1000 (x, y)
extent : -18040094, 18040906, -7363043, 9018957 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs
data source : C:\Users\Mafalda\Desktop\Iva\HumanFootprintv2\hfp2009.asc
names : hfp2009
values : -2147483648, 2147483647 (min, max)
hfpResamp <- resample(hfp, alt, resample='bilinear')
show(hfpResamp)
class : RasterLayer
dimensions : 1800, 4320, 7776000 (nrow, ncol, ncell)
resolution : 0.08333334, 0.08333334 (x, y)
extent : -180, 180, -60, 90.00001 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs
data source : in memory
names : hfp2009
values : NA, NA (min, max)
extent(hfp)
class : Extent
xmin : -18040094
xmax : 18040906
ymin : -7363043
ymax : 9018957
extent(alt)
class : Extent
xmin : -180
xmax : 180
ymin : -60
ymax : 90.00001
解决方案
reproject
您需要先保存hfp
文件:
hfp_re <- projectRaster(hfp, alt)
# now you can resample:
hfpResamp <- resample(hfp_re, alt, resample='bilinear')
推荐阅读
- javascript - 如何使用内容安全策略允许执行 .NET 自动生成的内联 JavaScript?
- android - 上下文未解决的参考
- f# - 无法让 WebSharper Javascript 客户端在 Suave 上运行
- reactjs - Firebase - firestore createdAt 时间戳 - 反应
- android - 如何使用新的 androidx.lifecycle:*:2.2.0-alpha01 获取生命周期.coroutineScope
- javascript - 有没有办法在 Selenium 版本 4 和更高版本中以无头模式执行 UI 测试?
- ios - 在 AVPlayerViewController 中播放视频时单击主页按钮时如何停止关闭 iOS 应用程序
- javascript - 传播事件时如何获取按钮值
- java - 需要验证用户输入的包含字母和数字的代码
- excel - 从 Excel 打印到 pdf 时自动分页