Dear friends, Do you know how to calculate the CONCAVE hull of a set of points (2- dimensional or n-dimensional)? is that possible in R? (With a "smoothing" parameter of course). Best, -- Corrado Topi Global Climate Change & Biodiversity Indicators Area 18,Department of Biology University of York, York, YO10 5YW, UK Phone: + 44 (0) 1904 328645, E-mail: ct529 at york.ac.uk
See the function 'convhulln' in the 'geometry' package. It uses this algorithm : http://www.qhull.org/ remko ------------------------------------------------- Remko Duursma Post-Doctoral Fellow Centre for Plants and the Environment University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908 www.remkoduursma.com On Thu, Nov 26, 2009 at 3:37 AM, Corrado <ct529 at york.ac.uk> wrote:> Dear friends, > > Do you know how to calculate the CONCAVE hull of a set of points (2- > dimensional or n-dimensional)? is that possible in R? (With a "smoothing" > parameter of course). > > Best, > -- > Corrado Topi > > Global Climate Change & Biodiversity Indicators > Area 18,Department of Biology > University of York, York, YO10 5YW, UK > Phone: + 44 (0) 1904 328645, E-mail: ct529 at york.ac.uk > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
This is not a true convave hull, but a 2D density is something similar and perhaps more "statistical": library(MASS) xx <- runif(100, 0, 1) xx <- runif(100, -1, 1) yy <- abs(xx)+rnorm(100,0,.2) dens2 <- kde2d(xx, yy, lims=c(min(xx)-sd(xx), max(xx)+sd(xx), min(yy)-sd(yy), max(yy)+sd(yy) ) ) contour(dens2, add=TRUE) # You can pick a single contour if you like: contour(dens2, level=0.05, col="red", add=TRUE) contour(dens2, level=0.10, col="blue", add=TRUE) Happy Valentine's -- David On Nov 25, 2009, at 11:37 AM, Corrado wrote:> Dear friends, > > Do you know how to calculate the CONCAVE hull of a set of points (2- > dimensional or n-dimensional)? is that possible in R? (With a > "smoothing" > parameter of course). > > Best, > -- > Corrado Topi > > Global Climate Change & Biodiversity Indicators > Area 18,Department of Biology > University of York, York, YO10 5YW, UK > Phone: + 44 (0) 1904 328645, E-mail: ct529 at york.ac.uk > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD Heritage Laboratories West Hartford, CT
Hi, I just want to add a possible solution to the problem in the special case all the points must stay on the edge of the outline. THis is sometimes the case when doing image analysis and you want to order the points along a closed path. In this specific case, you can use some algorithm like the traveling salesman problem, which would give you the shortest path along all your points. In this scenario, if your points are xy, you may use the following: library(TSP) tsp <- TSP(dist(xy)) tour <- solve_TSP(tsp,method='farthest') xy <- xy[tour,] THis may not be the most economical solution (and you might also want contrains such as never to intersect the path) and is not valid if your boundary is not supposed to pass through all points. -- View this message in context: http://r.789695.n4.nabble.com/Concave-hull-tp863710p4688606.html Sent from the R help mailing list archive at Nabble.com.
Maybe Matching Threads
- Error "singular gradient matrix at initial parameter estimates" in nls
- A point in a vector?
- Strange error returned or bug in gam in mgcv????
- goodness of "prediction" using a model (lm, glm, gam, brt, regression tree .... )
- From THE R BOOK -> Warning: In eval(expr, envir, enclos) : non-integer #successes in a binomial glm!