How can I speed up extraction of the proportion of land cover types in a buffer from a raster?

一笑奈何 提交于 2019-12-05 06:39:07

Here is a more concise formulation

library(raster)
library(rgeos)

buf_line <- gBuffer(seg_line, width=10000, byid=TRUE)
ha <- extract(x=data_raster, y=buf_line)
h <- sapply(ha, function(x) tabulate(x, 10))
h <- h / colSums(h)

But I do not think this will be much faster. Instead of extract you could try sp::over

Depending on your computer, things might speed up by first running

beginCluster()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!