The standard R tool is ellipsoidhull in the cluster package (which is a recommended R package and should be installed with your R). That will draw a minimum volume ellipsoid enclosing your points. See its documentation for further hints (like MASS::cov.vme). The cluster package also provides volume.ellipsoid function to find the volume. Obviously, these work in 2D.
Cheers, Jari Oksanen > On 30 Sep 2015, at 17:38 pm, Baldwin, Jim -FS <jbald...@fs.fed.us> wrote: > > One metric for an "average width" that would be quick to calculate might be > the diameter of a circle that has the same area as the polygon. (Of course, > if the tree crowns are nowhere near circular, this won't likely be a useful > metric.) Maybe there might be a similar approach for finding an ellipsoid > with the same area to deal with your desire for an "eccentricity" metric. (A > fanciful approach might be to perform a principal components analysis on a > grid (or dense random selection) of points in the polygon and use the > "variance explained" for the two principal components to create the > semi-major and semi-minor axes of an ellipse. In any event, the usefulness > of any metric will be based on how well it predicts or is associated with > some other variable or variables of interest.) > > Jim > > > -----Original Message----- > From: R-sig-ecology [mailto:r-sig-ecology-boun...@r-project.org] On Behalf Of > Alexander Shenkin > Sent: Wednesday, September 30, 2015 3:10 AM > To: r-sig-ecology@r-project.org > Subject: [R-sig-eco] Quantifying widths of polygons > > Hello all, > > I am working with data on tree crowns, and this data describes points > (verticies) around the polyhedron of the crown volume (think of the crown as > a single volume with vertices and faces). I can calculate maximum z distance > between any 2 points (maximum depth) and maximum x/y distance (maximum > width). These are useful metrics. I would also like to quantify an > "average" width of the polygon in 2D space (x/y only), as well as a metric > that would describe the "eccentricity" of the polygon. > But, I'm not sure how to go about doing that. > > In general, I've made the polyhedrons and polygons into convex shapes. > > I have considered getting a centroid, intersecting lines every 10 degrees > (for example) going through the centroid with the x/y polygon owin in > spatstat, and then analyzing those line lengths. But, I'm not sure that's > the right way to go, and maybe there are already tools out there to do this. > Any thoughts anyone might have would be very welcome! > > Thanks, > Allie > > (btw, I posted this on R-help (and on R-sig-ecology with no response), and it > was suggested that a list such as this would be more appropriate... apologies > for the cross-post) > > > library(rgl) > library(spatstat) > library(geometry) > x = > c(1.9,-1.4,1.5,1.8,2.2,0.2,0.6,-0.9,-3.7,1.3,-1.9,-3.4,3.7,2.1,-2.0,-1.9) > y = > c(-3.1,3.0,1.1,-1.3,1.0,0.0,1.4,1.6,2.3,-3.6,-1.5,-1.3,0.3,-2.1,0.2,-0.3) > z = c(5.5,4.5,4.3,4.8,6.7,5.8,7.4,6.2,3.5,2.9,4.0,3.7,3.2,3.0,3.1,8.4) > depth = max(z) - min(z) > width_max = max(dist(matrix(c(x,y),ncol=2))) > > xy_win = owin(poly=list(x=x,y=y)) > conv_win = convexhull(xy_win) > # from here, maybe draw lines every 10 degrees through a centroid? > # avg_width = ?? > # eccentricity = ?? > > # 3D plot of crown polyhedron (convex) > ps = data.frame(x=x,y=y,z=z) > crown.surf = t(convhulln(matrix(c(x,y,z),ncol=3))) > open3d() > rgl.triangles(ps[crown.surf,1],ps[crown.surf,2],ps[crown.surf,3],col=heat.colors(nrow(ps)),alpha=.2) > axes3d() > > _______________________________________________ > R-sig-ecology mailing list > R-sig-ecology@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology > > _______________________________________________ > R-sig-ecology mailing list > R-sig-ecology@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology _______________________________________________ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology