[R-sig-Geo] Unexpected output from distfun
Rolf Turner
r.turner at auckland.ac.nz
Sun Jan 15 04:15:57 CET 2012
Okay --- I think I've tracked it down. The problem is (I believe) with
the value
of "huge" in the nncross() function --- which just isn't huge enough.
It was taken
to be the diameter of X$window, which could in fact be quite small
relative to
the distances between the points of X and the points of Y (and will in
fact be
*zero* when applying the function returned by distfun() if the argument to
distfun() has only one point).
I've amended nncross() to take "huge" to be the diameter of
union.owin(X$window,Y$window)
This seems to work ... although there may be a better strategy. (Over
to you,
Adrian).
I have attached my amended version of nncross, which you can source into
you can use until a release of "spatstat" containing this, or a more
appropriate fix
comes out.
Note that you need to do
assignInNamespace("nncross",nncross,"spatstat")
after sourcing in nncross.R, otherwise distfun() will use the "old"
version of nncross
rather than the amended one. And you have to (psigh!) do the
assignInNamespace()
thing each time you start a new R session, in order to get the right
nncross() function
being called.
cheers,
Rolf Turner
On 15/01/12 11:55, ONKELINX, Thierry wrote:
> Dear all,
>
> I'm not getting the output I'm expecting when using distfun() from the
> spatstat package. Any idea what is going wrong?
>
> Best regards,
>
> Thierry
>
> library(spatstat)
> w <- owin(xrange = c(-10, 10), yrange = c(-10, 10))
> P <- ppp(x = 0, y = 0, window = w)
> P1 <- ppp(x = 1, y = 0, window = w)
> P2 <- ppp(x = 1:2, y = c(1, 1), window = w)
> P3 <- ppp(x = 2:1, y = c(2, 2), window = w)
> f <- distfun(P)
> f2 <- distfun(P2)
> fo <- list(f(P1), f(P2), f(P3))
> fo2 <- list(f2(P), f2(P1), f2(P3))
>
> > fo
> [[1]]
> [1] 0
>
> [[2]]
> [1] 1 1
>
> [[3]]
> [1] 1 1
>
> > fo2
> [[1]]
> [1] 0
>
> [[2]]
> [1] 0
>
> [[3]]
> [1] 1 1
>
> > sessionInfo()
> R version 2.14.1 (2011-12-22)
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> locale:
> [1] LC_CTYPE=nl_BE.UTF-8 LC_NUMERIC=C
> [3] LC_TIME=nl_BE.UTF-8 LC_COLLATE=nl_BE.UTF-8
> [5] LC_MONETARY=nl_BE.UTF-8 LC_MESSAGES=nl_NL.UTF-8
> [7] LC_PAPER=C LC_NAME=C
> [9] LC_ADDRESS=C LC_TELEPHONE=C
> [11] LC_MEASUREMENT=nl_BE.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] spatstat_1.25-1 deldir_0.0-16 mgcv_1.7-12
>
> loaded via a namespace (and not attached):
> [1] grid_2.14.1 lattice_0.20-3 Matrix_1.0-3 nlme_3.1-102
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20120115/5f91f1eb/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: nncross.R
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20120115/5f91f1eb/attachment.pl>
More information about the R-sig-Geo
mailing list