我有一个从中创建多点对象的数据框:
points = MultiPoint(list(zip(dfxT['x'], dfxT['y'])))
dfxT看起来像这样:
x | y | xT
2 3 1
2 15 5
2 28 6
这是Multipoint
输出:
现在我有了一个新的坐标元组,我想检查它们是否位于Multipoint
对象内,然后获取x
和y
并从数据框中检索对应的xT
。
所以基本上我是这样做的:
p = Point(10, 42)
a = points.intersection(p)
不返回任何内容。我想我正在尝试查看该点是否在多点内并获取我想要的东西,我认为我应该获取最接近的点并将其.loc
放在我的数据框中。
所以问题是:如何从x
中最接近的y
获得Point
和Multipoint
坐标?
感谢@Georgy,我找到了解决方案!去:
p = Point(10, 42)
nps = nearest_points(points, p)[0]
xt_pts = np.array(nps).tolist()
谢谢!