R中的错误:栅格中的focus函数的“无适用方法”

问题描述

我想应用一个移动窗口(3x3)来估算异构景观上的条件熵(Nowosad&Stepinsky,2019):

entropy=function(r){
  entropy=lsm_l_condent(r,neighbourhood = 4,ordered = TRUE,base = "log2")
  return(entropy$value)
}
w=matrix(1,3,3)
result=focal(r,w,fun=entropy)

但是,出现此错误:

Error in .focal_fun(values(x),as.integer(dim(out)),runfun,NAonly) : 
Evaluation error: no applicable method for 'lsm_l_condent' applied to an object of class "c('double','numeric')".

但是,当我在整个环境中运行熵函数时,它会起作用:

> entropy(r)
[1] 2.178874

r是INT4U栅格对象:

class      : RasterLayer
dimensions : 886,999,885114  (nrow,ncol,ncell)
resolution : 300,300  (x,y)
extent     : 934805.7,1234506,1006566,1272366  (xmin,xmax,ymin,ymax)
crs        : +proj=tmerc +lat_0=4.59620041666667 +lon_0=-74.0775079166667 +k=1 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0 +units=m +no_defs
values     : 99,321113  (min,max)

是否有解决“无适用方法”错误的想法?还是有任何想法可以通过移动窗口来估计条件熵?

预先感谢您的帮助。

最好

Jaime

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...