14

Suppose I have a irregular, random, shape generated from a dataset. How do I find points that are situated on the shape's border?

I am using R. Are there any packages in R for this purpose? For simplicity, just assume that I have a 2d dataset of points.

csgillespie
  • 59,189
  • 14
  • 150
  • 185
Pradeep
  • 555
  • 8
  • 14
  • 3
    A [convex hull](http://en.wikipedia.org/wiki/Convex_hull) is the technical term for the "border" of your dataset. Using "convex hull" when searching may help generate good results. – Sharpie Feb 08 '11 at 19:03
  • 2
    Noticed you haven't accepted an answer on any of your questions. Please do so by clicking on the V sign to the left. This will reward the people that were so generous to answer you, and tell other visitors the answer was helpful. See also the FAQ – Joris Meys Apr 15 '11 at 15:21

2 Answers2

19

You are looking for the chull() function to compute the convex hull of a 2D object, in package grdevices.

Here is the example from the online help:

require(stats)
X <- matrix(rnorm(2000), ncol = 2)
chull(X)
## Not run: 
# Example usage from graphics package
plot(X, cex = 0.5)
hpts <- chull(X)
hpts <- c(hpts, hpts[1])
lines(X[hpts, ])

enter image description here

Gavin Simpson
  • 170,508
  • 25
  • 396
  • 453
Andrie
  • 176,377
  • 47
  • 447
  • 496
2

These functions (packages) seem adequate:

  • ahull (alphahull)
  • convex.hull (tripack)
  • chull (grDevices)
  • in.chull (sgeostat)
  • convhulln (geometry)
  • convexhull.xy (spatstat)
  • calcConvexHull (PBSmapping)
petermeissner
  • 12,234
  • 5
  • 63
  • 63