[R] spatial overlap of datasets

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Mon Nov 19 15:11:06 CET 2007


uimbpv wrote:
> Hi,
> 
> I have two datasets for which I have used cmdscale (to scale them to
> for example 6 dimensions) and then I got their convex hulls. I need to
> check if the two convex hulls/areas enclosed by these overlap - would
> I be able to do that in R?
>

Let A and B be the sets of points of the two convex hulls.

If any of the points of A fall inside B or vice versa then the convex 
hulls overlap.

So:

  for pointI in A:
    if convexhull(B + pointI) == convexhull(B) then:
      pointI is inside convex hull of B, so return(overlap)

  repeat for pointI in B to check the vice-versa. If the loop falls 
through then none of the hull points are in the other hull's convex hull 
and so there's no overlap.

  There's probably quicker ways, but you did say 'any ideas are 
appreciated'!

Barry



More information about the R-help mailing list