0

When I use the alphahull library for determining whether a point belongs to a alpha-convex hull or not (inahull), I'm getting a FALSE for points that are clearly inside the alpha convex hull. I've tried different ways of handling the data but it seems that inahull doesn't work properly (or I don't know how to use it ;) )

library(alphahull)
data<-read.table("f2",h=T)
plot(x=x$alpha,y=x$beta, log="y")

Now, I select a set of points for creating a subspace in the plot

sp<-locator(30, type='p', pch=20)
sp
$x
[1] 16.91776 24.41393 36.14421 46.46116 43.34893 27.61219 16.99911
$y
[1] 31.74403 55.32414 68.87334 30.98970 15.31316 11.20075 15.14894

hull<-ahull(sp,alpha=1000)

Now, I add them to the plot just to check:

plot(hull, add=T)

(So far it looks good) Now, if I check that these points are inside the shape (which are clearly inside):

inahull(hull, c(30,40))
FALSE

The data that I'm using can be found in this link: https://drive.google.com/file/d/0B8gPXQL4u-b_c2RxNHNGcE5TOVk/edit?usp=sharing

A problem using alphahull was also reported here: Row ordering for polygons

Thanks for your time and help!

Community
  • 1
  • 1
LeonLara
  • 61
  • 5
  • Can you please make your code reproducible without external links? I suggest generating some phantom data using `rnorm` or such. – Roman Luštrik Jun 23 '14 at 19:23
  • @RomanLuštrik if I try the example code in the alphahull library, it works. In a different question using alphahull (see last link) the OP also had a problem related to his/her particular data. That's why I think providing my data could be important. – LeonLara Jun 23 '14 at 19:28
  • I'm just trying to help you make your problem 'stuck' to SO. If a link on google drive goes down, your question becomes less interesting for future generations. That's why I thing it would be a blast if you could simulate some data that demonstrate the same problem. It also helps you understand the problem better. I solve most of my problems by creating a MRE (minimal reproducible example). See http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Roman Luštrik Jun 24 '14 at 06:05
  • I just came across the same problem. I had spatial data that had to be transformed to an equal area projection, resulting in coordinates that were in the order of 10^6. The inahull() function wouldn't cope with this - I did some testing and found that it would work for coords of magnitude up to about 1000 or so, no idea why this is the case. But in the end I simply divided my coordinate system by a factor of 10^6 so the numbers were of the order of 1. Then inahull() seemed to work fine. Still testing but I think I'll go with this workaround. – Stuart Allen Feb 04 '15 at 10:12

0 Answers0