更快的有效方法在R中裁剪NetCDF
我有一个.NC/NETCDF文件,大小约为1GB。尝试通过以下代码裁剪并使其更小:
r <- terra::rast("myfile.nc")
r2 <- terra::crop(x = r, y=terra::ext(-79, -72, 0, 12.4))
在16GB RAM机器中失败。通过失败,我的意思是,如果我试图停止运行代码,它不会在15分钟内返回任何结果,并冻结我的rstudio会话。因此,我没有错误消息要在此处发布。
我应该考虑在NetCDF文件上使用Terra :: crop()
哪种替代方案?
I have a .nc/netcdf file which is about 1GB in size. Trying to crop and make it smaller with the following code:
r <- terra::rast("myfile.nc")
r2 <- terra::crop(x = r, y=terra::ext(-79, -72, 0, 12.4))
fails in a 16GB RAM machine. By failing I mean it does not return any results in 15 minutes and freezes my RStudio session if I try to stop the running code. Thus I have no error message to post here.
What alternative to terra::crop()
should I consider to use on netcdf files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在使用(使用)GDAL(标准方法)GDAL时,使用多层(时间步长)处理(NETCDF)文件,这就是Terra使用的。我希望在未来几个月内解决这个问题。您想做的事情可能会使用
栅格
来快得多,因为它将数据作为三维数组接近(它不在图层上循环)。所以我建议Dealing with (NetCDF) files with many layers (time steps) can be very slow when using (a standard approach with) GDAL, which is what terra uses. I hope to fix this over the coming months. What you want to do may go much faster with
raster
because it approaches the data as a three-dimensional array (it is not looping over layers). So I would suggest