【问题标题】:why do I get NA values when resampling rasters in r为什么在 r 中重新采样栅格时会得到 NA 值
【发布时间】:2018-05-18 13:40:51
【问题描述】:

我有两个不同程度的栅格,但是当我在 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 

【问题讨论】:

  • 看起来您的栅格 hfp 已投影

标签: r raster


【解决方案1】:

你需要先reproject你的hfp文件:

hfp_re <- projectRaster(hfp, alt)
# now you can resample:
hfpResamp <- resample(hfp_re, alt, resample='bilinear')

【讨论】:

  • 您必须首先为您的 htf 光栅定义投影。当前参考不正确。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-20
  • 2019-11-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多