[R-sig-Geo] "no applicable method" for focal() function in raster

Jaime Burbano Girón j@|mebg27 @end|ng |rom gm@||@com
Mon Sep 14 22:41:43 CEST 2020


Hi everyone,

I want to apply a moving window (3x3) to estimate conditional entropy
(Nowosad & Stepinsky, 2019) over a heterogeneous landscape:
*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)*

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

But, when I run entropy function in the entire landscape it works:

*> entropy(r)[1] 2.178874*

*r* is a INT4U raster object:






*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,0,0,0,0,0 +units=m +no_defs values
  : 99, 321113  (min, max)*

There is any idea to solve the "no applicable method" error? Or any idea to
estimate conditional entropy applying a moving window?

Thanks in advance for the help.

Best,

Jaime

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list