# [R] Concave Hull?

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Wed May 3 00:16:56 CEST 2006

```On 02-May-06 Mike Saunders wrote:
> I am modeling a trend surface using trmat and want to trim the
> resulting matrix to the area enclosed by my real data (i.e.,
> remove all the extrapolated areas).  I was using chull and
> in.chull to calculate the convex hull and change all the other
> values created by trmat to NA. However, my real data has portions
> that are slightly concave so chull would give me slivers that are
> extrapolations from my data.  Is there some other type of "chull"
> function that will allow the resulting polygon to be slightly
> concave?  (I can send a picture to show what I am trying to do,
> if needed)

If I understand you correctly, what you are trying to do is not
well-determined, though one can think of ways of achieving the
general aim.

One approach might be to replace each segment of the convex hull
by a circular arc, pulled perhaps towards the centroid until it
first meets an interior point.

Or you might, for each bounding segemtn fo the convex hull:

1: Select the nearest interior point to a boundary segment, and
make it the vertex of a triangle whose other two are the
end-points of the segment; then remove the segemnt. Or:

2: Select the two nearest points to the segment and, along with
the two end-points, make the convex hull of these four points;
then remove the segment. Or:
...
k: Select the k nearest points to the segment and make the convex
hull of these k+2 points; then remove the segment. ...

Come to think of it, perhaps your picture might help!

Best wishes,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 02-May-06                                       Time: 23:16:52
------------------------------ XFMail ------------------------------

```