如何使用lat和lon索引R栅格砖

时间:2018-05-16 16:51:18

标签: r indexing raster

我构建了一个栅格砖,每个层代表地球的年平均温度图。栅格砖看起来像这样:

d <- structure(list(word = c("apples", "apples", "melon", "curcuma", 
                             "banana", "kiwi", "grape", "curcuma", "grape", 
                             "wood", "satsuma", "melon", "raisin", "papaya", "plum", 
                             "plum", "papaya", "banana", "satsuma", "peach"), u_c = c("candidate", 
                                                                                      "user", "user", "candidate", "user", "candidate", "user", "user", 
                                                                                      "candidate", "user", "user", "candidate", "user", "candidate", 
                                                                                      "candidate", "user", "user", "candidate", "candidate", "candidate"
                             ), n = c(0.56704584625991, 0.273789875549109, 0.190633674260422, 
                                         0.105308514305412, 0.0914084706627656, 0.0565322302654257, 0.0562029558128485, 
                                         0.0547338017954938, 0.0498104102033781, 0.0439600056682254, 0.0393399851625864, 
                                         0.0380903136849362, 0.0370685271783074, 0.0370561875215443, 0.035849706997587, 
                                         0.0352763676677753, 0.0325506180866405, 0.0206825232678387, 0.0198207514650121, 
                                         0.0113753877973113)), class = c("tbl_df", "tbl", "data.frame"
                                         ), row.names = c(NA, -20L))

我希望能够通过单元格位置提取向量,从而为我提供该单元格的时间序列。我能够像这样使用行号和列号:

> x
class       : RasterBrick 
dimensions  : 360, 720, 259200, 110  (nrow, ncol, ncell, nlayers)
resolution  : 0.5, 0.5  (x, y)
extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
data source : /Users/kirkw/R_code/rgis/test.grd 
names       :   layer.1,   layer.2,   layer.3,   layer.4,   layer.5,   layer.6,   layer.7,   layer.8,   layer.9,  layer.10,  layer.11,  layer.12,  layer.13,  layer.14,  layer.15, ... 
min values  : -57.59665, -56.89876, -57.92206, -55.95920, -57.09456, -55.45393, -55.38048, -57.27017, -56.05618, -56.92603, -57.68953, -55.23584, -56.70047, -56.50427, -56.72116, ... 
max values  :  30.52231,  30.49426,  29.96689,  30.05002,  30.13025,  30.08621,  29.73001,  30.27164,  30.00519,  30.15961,  30.15723,  30.53934,  30.00043,  30.47162,  30.45111, ...

但是,我想通过lat和lon提取数据,但到目前为止,还没有想出一个完成的方法。任何想法都会非常感激。

0 个答案:

没有答案