[R] inout() in splancs working properly?

Roger Bivand Roger.Bivand at nhh.no
Mon Jun 4 14:14:00 CEST 2001


Rainer:

On Sat, 2 Jun 2001, Rainer Hurling wrote:

> I have a problem with function 'inout()' in package 'splancs' on CRAN-R
> Version 1.2.3 under FreeBSD4.3-STABLE.
> 
> The following script produces and draws points and a polygon-surrounded
> area. Repeating the same script many times shows, that points on the
> polygon-line often, but not always, are outside of the polygon-area.
> 
> If points lay on the polygon-line, inout() tells sometimes they are
> inside (black points), sometimes outside (red points) of the surrounded
> (here ligthblue) area.
> 
> Is my understanding of function inout() correct? I am looking for a
> function, that gives all points inside the area, including points laying
> on the polygon-line, as 'TRUE' or 'inside'.
> 
Yes and no. Computational geometry is a black art, and point-in-polygon
algorithms usually return the answer to whether the point is inside the
polygon or not (inside meaning inside the boundary). Some algorithms will
also tell you whether the point is on the (vanishingly thin) boundary
itself.

In your trial case, the vertices of the convex hull are both in the set of
points being tested and are actual boundary vertices, a very untypical
situation in empirical settings. If you "jittered" them so that they
didn't coincide exactly in their binary representation, the algorithm
would answer happily either yes or no - as it is, it says that boundary
points may be either in or not, depending (somewhat) on where your vertex
is around the boundary.

There is no general acceptance for points on boundaries being either
inside or outside, but in the next splancs release, the documentation will
be changed to reflect this issue, and I may try some alternative
algorithms to give three replies, and the user the choice of including
points on boundaries.

Hope this helps,

Roger

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no
and: Department of Geography and Regional Development, University of
Gdansk, al. Mar. J. Pilsudskiego 46, PL-81 378 Gdynia, Poland.

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list