Rspatial terra::flip 需要 2 个多小时才能翻转 rast 对象,然后失败并显示以下错误:错误:[flip] 不正确的开始和/或 nrows 值

Rspatial terra::flip takes over 2 hours to flip a rast object, and then fails with this error: Error: [flip] incorrect start and/or nrows value

提问人:Dulci 提问时间:10/24/2023 最后编辑:Dulci 更新时间:10/31/2023 访问量:41

问:

我正在使用 terra (1.7.57) 打开和操作一个大的 .nc 文件。此栅格将倒置打开。我正在使用 terra::flip 垂直翻转栅格的所有图层。翻转栅格需要 20 分钟到 2 小时,然后出现以下错误: 错误:[flip] 不正确的开始和/或 nrows 值

我尝试通过选择所需的图层来对栅格进行子集化,但发生了相同的错误。我尝试在分配 CRS 和范围之前和之后翻转栅格,结果相同。

输入的 .nc 文件是 5G。可在此处获得:https://drive.google.com/drive/folders/1p6SkrYjtaAhFXYnUsR1jX-mYa_jtUSop?usp=drive_link

为什么会出现此错误,故障排除的下一步是什么?

这是我的代码:

    require(terra)

    s2file <- "S2B_MSI_2021_04_14_18_49_19_T10SFH_L2W.nc"

    rastcrs <- "+proj=utm +zone=10 +datum=WGS84 +units=m +no_defs"
    extent <- c(600000, 709800, 4190220, 4300020)

    S2Rrsf <- rast(s2file)
    crs(S2Rrsf) <- rastcrs
    ext(S2Rrsf) <- rextent
    S2Rrs <- subset(S2Rrsf, c(31:41, 12:15, 3:5))

    S2Rrs <- terra::flip(S2Rrs, direction = "vertical")`

S2Rrs 对象标识信息:

S2Rrs
class       : SpatRaster 
dimensions  : 5490, 5490, 18  (nrow, ncol, nlyr)
resolution  : 20, 20  (x, y)
extent      : 6e+05, 709800, 4190220, 4300020  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=10 +datum=WGS84 +units=m +no_defs 
sources     : S2A_MSI_2019_07_19_18_49_21_T10SFH_L2W.nc:Rrs_443  
              S2A_MSI_2019_07_19_18_49_21_T10SFH_L2W.nc:Rrs_492  
              S2A_MSI_2019_07_19_18_49_21_T10SFH_L2W.nc:Rrs_560  
              ... and 15 more source(s)
varnames    : Rrs_443 (Remote sensing reflectance) 
              Rrs_492 (Remote sensing reflectance) 
              Rrs_560 (Remote sensing reflectance) 
              ...
names       : Rrs_443, Rrs_492, Rrs_560, Rrs_665, Rrs_704, Rrs_740, ... 
unit        :       1,       1,       1,       1,       1,       1, 
netcdf terra 哨兵2

评论

0赞 Robert Hijmans 10/24/2023
你能分享那个文件吗?例如,将其放在 Google Drive 或类似内容上,然后将链接添加到您的问题中。
0赞 Dulci 10/24/2023
是的!上传需要几个小时。当问题可用时,我会对其进行编辑。
0赞 Dulci 10/31/2023
数据集链接已编辑!
0赞 Robert Hijmans 11/1/2023
请问您能否授予对该文件的公共访问权限?
0赞 Dulci 11/2/2023
不好意思!访问已更新

答: 暂无答案