为什么在 r 中对栅格进行重采样时会获得 NA 值

  • 本文关键字:重采样 NA r raster
  • 更新时间 :
  • 英文 :


我有两个不同范围的栅格,但是当我使用重新采样时,输出是一个空白栅格......如何解决问题? 请参阅下面的一些使用的代码。值中带有 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:UsersMafaldaDocumentsbio_5m_esrialt5.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:UsersMafaldaDesktopIvaHumanFootprintv2hfp2009.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 

您需要先reprojecthfp文件:

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

最新更新