Closed mzeybek583 closed 5 years ago
I don't have such issue running your code. Please retry your code in a fresh session and confirm it is reproducible. An example from the doc necessarily works because it is regularly tested. One exception in rare cases where the code is surrounded by #DONTRUN
Anyway the following syntax should be preferred everywhere in lidR.
metrics = grid_metrics(las, ~myMetrics(Z, Intensity))
Hmm. It is interesting. As you pointed, when I clearly run the code it works. But when I run this,
myMetrics = function(z)
{
mm =list(out = boxplot(z,plot = FALSE, outline = TRUE))
#ind = which(!veri2$Z %in% out, arr.in= TRUE)
return(mm)
}
metrics = grid_metrics(veri, myMetrics(Z), 100)
this code gives an error. After, I run the help page code it produces the same error again.
Thanks Romain.
I can't reproduce.
But as I said use ~myMetrics(Z)
. In the next release (v2.1) I changed the documentation to add the ~
in the examples. Former syntax will still work but I included the ~
everywhere to avoid many problems of this kind.
Btw your code gives an error (you don't have the same error yet and your error will be more cryptic (see also https://github.com/Jean-Romain/lidR/issues/227#issuecomment-465651949)).
metrics = grid_metrics(las, myMetrics(Z), 100)
#> Erreur : Duplicated pixels found. At least one of the metrics was not a number. Each metric should be a single number.
What you are trying to compute is incorrect. If you don't understand why please ask on https://gis.stackexchange.com/
Ciao JR,
sorry for re-opening but, looking for the abovementioned lazy_eval
error, this thread was among the few useful things that popped up.
I'm getting the same issue rasterizing my own pretty long (138 vars) function.
r = grid_metrics(las, ~vofun(X,Y,Z), res=1)
Does the error mean that the algorithm is not able to evaluate the ~vofun(X,Y,Z)
argument or that within the function there might be any other kind of issue? in this last case, the presence of NA
are an issue for the rasterization process?
I don't see any other potential issue and still don't find useful info online on how to "debug" it. thanks in advance
right now I found a workaround applying the same function a little tweaked to work on catalog
and it works fine...but obviously then I have to rasterise every single variable
Please provide a reproducible example.
Reproducible example sent by email. Error confirmed.
I found your issue. As mentioned in the documentation you should always use the ~
in grid_metrics
as well as in similar function. Without the ~
it works only at the first level (global_env). Do no ask me why. Here is your issue.
metr = lasmetrics(impLAS, ~stdmetrics_z(Z, dz=0.5))
Hi all, I have tried grid_metrics help page code. But it generated error. do you have any idea?
ERRO is here,
I thought, may it occurred due to the library error, I have installed lazyeval library but no luck.
platform x86_64-pc-linux-gnu
version.string R version 3.5.2 (2018-12-20) Rstudio Version 1.1.463