【发布时间】:2018-12-12 20:16:25
【问题描述】:
我正在使用光栅 CHM,我必须从多边形 shapefile 中提取多个指标。现在我正在做这样的事情:
library(raster)
library(sp)
#from the help page of extract
r <- raster(ncol=36, nrow=18, vals=1:(18*36))
cds1 <- rbind(c(-180,-20), c(-160,5), c(-60, 0), c(-160,-60), c(-180,-20))
cds2 <- rbind(c(80,0), c(100,60), c(120,0), c(120,-55), c(80,0))
polys <- spPolygons(cds1, cds2)
#metrics extraction
mean <- extract(r, polys,mean,df=T)
min<-extract(r, polys,min,df=T)
max<-extract(r, polys,max,df=T)
#and so on for other summary functions (like sd, mode, median, sum etc...)
我想知道是否有办法将所有汇总函数传递给 extract() 函数的 fun= 参数,以及是否可以并行执行。 感谢您的每一个帮助。
注意这是我在 StackOverflow 上的第一个问题,如有不当之处,我深表歉意
【问题讨论】:
-
也许更简洁的方法是编写一个函数来调用每个提取调用并返回所有结果的列表
标签: r parallel-processing extract