本文介绍了由 R 点云覆盖的区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个散布在二维欧几里得空间中的点云.我想计算连接云最极端(=外围)点的多边形内的面积.换句话说,我想估计这个空间中被云覆盖的面积.R中有公式吗?非常感谢您的任何回复朱利安

I have a cloud of points scattered in a 2D Euclidean space. I would like to calculate the area inside the polygon linking the most extreme (=peripheral) points of the cloud. In other words, I would like to estimate the area covered by the cloud in this space.Is there a formula in R?Thanks a lot for any responseJulien

推荐答案

这就是所谓的凸包问题;R 内置的 chull 函数应该可以完成这项工作.要计算面积,您可以使用 here 中的公式.

This is called the convex-hull problem; R built-in chull function should do the work. To count area, you may use a formula from here.

更好;splancs 包具有 areapl 功能.所以解决你的问题的函数应该是这样的:

Even better; splancs package has areapl function. So the function solving your problem should look like this:

cha<-function(x,y){
chull(x,y)->i
return(areapl(cbind(x[i],y[i])))
}

例如:

library(splancs);
x<-rnorm(20);rnorm(20)->y;
#Some visualization
i<-chull(x,y);plot(x,y);polygon(x[i],y[i]);
#The area
cha(x,y);

这篇关于由 R 点云覆盖的区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 06:12