Python。如何子采样点(X,Y)

2024-04-20 00:33:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个10000点的列表[x,y],但是它们彼此非常接近,所以我想用给定的距离阈值对这个列表进行子采样。 我不确定哪种方式最好,哪种方式正确。你知道吗

这是我的伪代码

coordinates = [x,y]
thresholdDist = 'some float value'
subsample = []
points = 'pick-some-random-points-from-coordinates'
for p in points:
    for c in coordinates:
        dst=EuclideanDistance(p, c)
            if dst <= thresholdDist:
                subsample.append(p and c)
set(subsample)

任何建议都很好。谢谢


Tags: 代码in距离列表forvalue方式阈值