r - 在栅格图层列表上应用函数
问题描述
我有一个像这样的 34 个 RasterLayers 列表:
[[34]]
class : RasterLayer
band : 1 (of 10 bands)
dimensions : 6899, 9663, 66665037 (nrow, ncol, ncell)
resolution : 0.0002694946, 0.0002694946 (x, y)
extent : -6.685352, -4.081226, 39.39795, 41.2572 (xmin, xmax, ymin, ymax)
crs : +proj=longlat +datum=WGS84 +no_defs
source : D:/TFM/Imagenes/Imagenes_sinClip/2017.tif
names : X2017
我想使用这样的裁剪列表的所有 RasterLayers simple feature
:
> aoi
Simple feature collection with 1 feature and 2 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -6.571744 ymin: 39.44875 xmax: -4.10362 ymax: 41.22031
Geodetic CRS: WGS 84
Id area geometry
1 0 29488.98 POLYGON ((-6.122013 41.2203...
为此,我使用了 lapply:
crop <- lapply(x = myrasterList, y = aoi, FUN = crop(x, y))
但我收到以下错误:
h(simpleError(msg, call)) 中的错误:在为函数“crop”选择方法时评估参数“x”时出错:对象“x”没有冲突
解决方案
lapply
当您向函数添加参数时,FUN 参数的工作方式并非如此。你需要做类似的事情
crop <- lapply(myrasterList, y = aoi, FUN = function(i) crop(i, y))
推荐阅读
- python - 删除元组外的数据框行
- php - WordPress 中的 username_exists 函数抛出 500 错误(函数未定义),尽管需要/包含 pluggable.php 和 user.php
- php - 无法选择 *(ORA-00932:不一致的数据类型:预期的 CHAR 得到了 ADT)
- tensorflow - 读取用于编码的特征未知的 TFRecord 文件
- python - 使用矩形边界框将图像切成文本行
- android - android webview中未显示“选择证书”对话框
- bash - FFMPEG:通过 RTP 的 32 通道流式麦克风
- powershell - 重新启动 powershell 脚本
- python - Scrapy/Django - PyCharm 调试器 - 无法导入模型
- angular - 如何将组件显示为全屏?