Search code examples
spatstat

cutoff error using custom kernel in Smooth.ppp


I need to use a custom kernel with the Smooth function, but attempting this throws an error even though I specify cutoff:

Error: The argument ‘cutoff’ is required when a non-Gaussian kernel is specified and scalekernel=FALSE

n=4; PPP=ppp(rep(1:n,n),rep(1:n,each=n), c(1,n),c(1,n), marks=1:n^2);
Smooth.ppp(PPP,cutoff=50,kernel=gaussian,at="points")

Here is a toy example that makes the same error. I'm not 100% sure whether this is an error or something that's unintuitive to me. Thank you!!


Solution

  • This is a bug. Thank you for bringing it to our attention.

    It has been fixed in the development version of spatstat.core (2.4-2.003) which is available at the GitHub repository

    The bug only affects the case where kernel is a function, at="points", and scalekernel=FALSE. In the meantime you can get the desired result by either

    1. Adding scalekernel=TRUE and sigma=1, or
    2. Deleting at="points" so that the result is a pixel image Z say, and extracting the desired values by Z[PPP].