我正在创建 ASCII 文件以包含在R
.
当我创建图层并查看栅格值时,我可以看到它们并且它们是正确的,例如:
> r_test3
class : RasterLayer
dimensions : 4698, 3919, 18411462 (nrow, ncol, ncell)
resolution : 50, 50 (x, y)
extent : 159500, 355450, 160454.6, 395354.6 (xmin, xmax, ymin, ymax)
crs : +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.999601272 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894
source : memory
names : layer
values : 1, 43385 (min, max)
然后当我堆叠三个栅格时,一切似乎都是正确的:
RegionalGridsBest
class : RasterStack
dimensions : 4698, 3919, 18411462, 3 (nrow, ncol, ncell, nlayers)
resolution : 50, 50 (x, y)
extent : 159500, 355450, 160454.6, 395354.6 (xmin, xmax, ymin, ymax)
crs : +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.999601272 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894
names : layer.1, layer.2, layer.3
min values : 1, 1, 1
max values : 43385, 92917, 95704
但是,当我getValues
为栅格时,他们只显示 NA:
> getValues(RegionalGridsBest)
layer.1 layer.2 layer.3
[1,] NA NA NA
[2,] NA NA NA
[3,] NA NA NA
[4,] NA NA NA
[5,] NA NA NA
[6,] NA NA NA
[7,] NA NA NA
[8,] NA NA NA
[9,] NA NA NA
[10,] NA NA NA
[11,] NA NA NA
[12,] NA NA NA
[13,] NA NA NA
然后由于这个原因,当我尝试使用该vifstep
功能时出现此错误:
vifstep(RegionalGridsBest, th = 3, maxobservations = 10000)
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
0 (non-NA) cases
我不知道如何解决这个问题或我做错了什么。
编辑
NA 值在文件中,尽管在创建层时设置为 0 值:
> summary(RegionalGridsBest)
Error in apply(object@data@values, 2, quantile, na.rm = TRUE) :
no slot of name "data" for this object of class "RasterStack"
> summary(r_test3)
layer
Min. 1.0
1st Qu. 18407.0
Median 28176.5
3rd Qu. 41293.0
Max. 43385.0
NA's 17850028.0
> summary(r_test2)
layer
Min. 1
1st Qu. 40505
Median 58967
3rd Qu. 75139
Max. 92917
NA's 17086764
> summary(r_test)
layer
Min. 1
1st Qu. 25570
Median 51215
3rd Qu. 66486
Max. 95704
NA's 17980349