R terra/raster:上载netcdf文件会改变分辨率

jw5wzhpr  于 2023-05-20  发布在  Etcd
关注(0)|答案(2)|浏览(296)

我有netcdf文件(GPM IMERG降水),应该是0.1x0.1分辨率,如底部的红框所示:

图像上的像素大小不完全是0.1,但至少它的高度和宽度是相同的。
但是,当通过terra::raster::上传netcdf时,分辨率会略有变化:

  1. class : SpatRaster
  2. dimensions : 185, 97, 1 (nrow, ncol, nlyr)
  3. resolution : 0.09999998, 0.1000001 (x, y)
  4. extent : 34.2, 43.9, 62.3, 80.80002 (xmin, xmax, ymin, ymax)
  5. coord. ref. : lon/lat WGS 84
  6. source : _(1).nc:precipitationCal
  7. varname : precipitationCal (Daily accumulated precipitation (combined microwave-IR) estimate)
  8. name : precipitationCal
  9. unit : mm
  10. time (days) : 2000-06-04

任何关于如何将R中的光栅转换回其原始分辨率的解决方案都将受到欢迎。顺便问一下,这与R包中范围的舍入坐标有关吗?

7nbnzgx9

7nbnzgx91#

你能指出那个文件吗?从我所看到的,要么是程度或网站上显示的分辨率是错误的。根据这些数字,应该是:

  1. print((43.9000038 - 34.20000855) / 97, digits=10)
  2. #[1] 0.09999995103

也许对于网站来说,分辨率是使用单元格的中心来计算的,这样你就可以得到

  1. print((43.95 - 34.15) / 97, digits=10)
  2. #[1] 0.1010309582

如果没有档案很难确定。但我会把我的钱放在网站上是错误的。
在你的档案里我还看到了这个

  1. f <- "__1_.nc"
  2. r <- rast(f)
  3. res(r)
  4. #[1] 0.09999998 0.10000007

但这是正确的,因为它确实反映了写入文件的x和y坐标。所提供的单元格的x和y坐标不是严格规则的(但几乎如此)。例如,下面是第一个和最后三个y坐标:

  1. 62.3500022888184 62.4500083923340 62.5499992370605 ...
  2. 80.5500030517578 80.6500091552734 80.7500152587891

仅从文件来看,我不能说这些小小数是故意的还是源于马虎,我假设是后者,在这种情况下,舍入范围似乎确实是合理的:

  1. ext(r) <- round(ext(r), 4)
  2. r
  3. #class : SpatRaster
  4. #dimensions : 185, 97, 1 (nrow, ncol, nlyr)
  5. #resolution : 0.1, 0.1 (x, y)
  6. #extent : 34.2, 43.9, 62.3, 80.8 (xmin, xmax, ymin, ymax)
  7. #coord. ref. : lon/lat WGS 84
  8. #source : __1_.nc:precipitationCal
  9. #varname : precipitationCal (Daily accumulated precipitation #(combined microwave-IR) estimate)
  10. #name : precipitationCal
  11. #unit : mm
  12. #time (days) : 2000-06-04
展开查看全部
iyzzxitl

iyzzxitl2#

修改范围边界似乎会更正分辨率。以下是上传后的文件范围:

  1. r<-rast("file")
  2. ext(r)
  3. SpatExtent : 34.2000038226446, 43.9000022808711, 62.3000022535739, 80.8000152940335 (xmin, xmax, ymin, ymax)

我对范围坐标的小数进行了四舍五入,并校正了分辨率:

  1. ext(r)<-c(34.2, 43.9, 62.3, 80.8)
  2. r
  3. class : SpatRaster
  4. dimensions : 185, 97, 1 (nrow, ncol, nlyr)
  5. resolution : 0.1, 0.1 (x, y)
  6. extent : 34.2, 43.9, 62.3, 80.8 (xmin, xmax, ymin, ymax)
  7. coord. ref. : lon/lat WGS 84
  8. source : _(1).nc:precipitationCal
  9. varname : precipitationCal (Daily accumulated precipitation (combined microwave-IR) estimate)
  10. name : precipitationCal
  11. unit : mm
  12. time (days) : 2000-06-04
展开查看全部

相关问题