获取坐标边界框,忽略边缘位置
我正在尝试围绕一组坐标创建一个边界框,但我想“关注”坐标组并忽略任何偏离并会弄乱地图的坐标。 (想象一张地图,其中一个城市有 10 个地点,另一个国家有 1 个地点)
构建左上角和右下角值的最佳方法是什么?
I'm trying to create a bounding box around a set of coordinates, but I want to 'focus' on groups of coordinates and ignore any that are way off and would mess up the map. (Imagine a map of 10 spots on a city and 1 somewhere in another country)
What would be the best way to build the top-left and bottom-right values?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,我将确定“边缘位置”的标准,
例如“2 σ 之外”,然后您只需计算两个维度的平均值并在 2 σ 处绘制线条。如果您想要一些弯曲的边界,那么事情会变得更加复杂......从您的标准开始,然后从那里继续前进。
因此,假设您想从平均值中排除超过 2σ 的事物,
您需要计算:
σ(x)、σ(y)、mean(x)、mean(y)
那么您的左上界是 (mean(x)- 2σ(x) ,mean(y)+2σ(y) )
和你的右下界是 (mean(x)+2σ(x) ,mean(y)-2σ(y) )
这将产生一个 2σ 的矩形两个维度。对于一个圆,事情会变得有点复杂......从定义你的“可接受区域”开始
First I would determine your criteria for "fringe locations"
Something like "outside 2 σ" then you just need to calculate your mean in both dimensions and draw your lines at 2σ. If you want some curvy boundary then things get much more complicated... Start at your criteria and move forward from there.
So let's assume you wanted to exclude things more than 2σ from the mean
You need to calculate:
σ(x), σ(y), mean(x), mean(y)
Then your upper left bound is ( mean(x)-2σ(x) , mean(y)+2σ(y) )
and your lower right bound is ( mean(x)+2σ(x) , mean(y)-2σ(y) )
this will yield a rectangle for 2σ in both dimensions. For a circle things will get a bit more complicated... start with defining you "acceptable region"
计算质心,然后选择最接近该质心的点。然后,丢弃任何超过某个恒定距离(或者可能是某个阈值,例如距该点一两个标准差)的点。现在,使用修剪后的点集重新计算。这样做直到您对结果感到满意为止(即所有点都在您定义的边界内)。
正如 Matthew PK 所说,这适用于简单的半径,但如果您想要某种类型的弯曲边界,则需要做很多额外的工作。
Compute the centroid, and then pick the point that's nearest that centroid. Then, throw out any point that's more than some constant distance (or, perhaps, some threshold like one or two standard deviations away from that point). Now, re-compute using the trimmed set of points. Do that until you're happy with the result (i.e. all points are within the boundaries that you define).
As Matthew PK said, this will work will for a simple radius, but if you want some type of curved boundary, it's a lot of additional work.
将您在统计课程中学到的知识运用到实践中;例如:
Put to work what you learned in your statistics courses; e.g.: