[英]R- Variables stored as Formal class RasterLayer, data content missing
Defining a new raster layer (Sentinel 2 MSI) 定义新的栅格图层(Sentinel 2 MSI)
> ras1 = raster ("T45QVG_20161209T045202_B02.jp2")
> summary (ras1)
1st Qu. 1160
Median 1230
3rd Qu. 1300
Max. 2221
NA's 0
Warning message:
In .local(object, ...) :
summary is an estimate based on a sample of 1e+05 cells (0.08% of all cells)
Now, assigning the defined raster layer to another variable 现在,将定义的栅格图层分配给另一个变量
> ras2 = raster (ras1)
> summary (ras2)
layer
Min. NA
1st Qu. NA
Max. NA
NA's NA
Also, 也,
> ras1
class : RasterLayer
dimensions : 10980, 10980, 120560400 (nrow, ncol, ncell)
resolution : 10, 10 (x, y)
extent : 399960, 509760, 2590200, 2700000 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=45 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : /home/riyas/Data/Work files/Data samples/Sentinel 2-MSI/S2A_MSIL1C_20161209T045202_N0204_R076_T45QVG_20161209T045602.SAFE/GRANULE/L1C_T45QVG_A007652_20161209T045602/IMG_DATA/T45QVG_20161209T045202_B02.jp2
names : T45QVG_20161209T045202_B02
values : 0, 65535 (min, max)
Contains all the values, but 包含所有值,但是
> ras2
class : RasterLayer
dimensions : 10980, 10980, 120560400 (nrow, ncol, ncell)
resolution : 10, 10 (x, y)
extent : 399960, 509760, 2590200, 2700000 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=45 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
After assigning to a new variable everything messed-up!! 分配给新变量后,一切都搞砸了!!
Calling raster
on a RasterLayer
object will only create an empty RasterLayer
object, which has the same attributes as the original object (such as extent, resolution, size) but has no values. 在
RasterLayer
对象上调用raster
只会创建一个空的RasterLayer
对象,该对象具有与原始对象相同的属性(例如范围,分辨率,大小),但是没有任何值。
Meaning, ras2 <- raster(ras1)
will create ras2
, which is an empty raster with Sentinel-2 dimensions. 这意味着
ras2 <- raster(ras1)
将创建ras2
,这是一个具有Sentinel-2尺寸的空栅格。 That's also why calling summary
is returning NA
s. 这就是为什么调用
summary
返回NA
的原因。
If you want to assign it to a new variable, so making a simple copy, you can just run ras2 <- ras1
. 如果要将其分配给新变量,以便进行简单复制,则只需运行
ras2 <- ras1
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.