gpt4 book ai didi

python - 来自单独数组中纬度/经度坐标的(纬度,经度)的所有可能点

转载 作者:太空宇宙 更新时间:2023-11-03 13:43:59 25 4
gpt4 key购买 nike

我在两个单独的数组中有纬度和经度坐标:

a = np.array([71,75])
b = np.array([43,42])

如何轻松找到由这些坐标组成的所有可能点?

我一直在摆弄 itertools.combinations:

In [43]:

list(itertools.combinations(np.concatenate([a,b]), r=2))

Out[43]:

[(71, 75), (71, 43), (71, 42), (75, 43), (75, 42), (43, 42)]

但这对我不起作用,因为点 (71,75)(43,42) 是纬度/纬度和经度/经度对。

我想要的是:

Out[43]:

[(71, 43), (71, 42), (75, 43), (75, 42)]

a 和 b 数组最终会变大,但会保持相同大小,因为它们是纬度/经度对。

最佳答案

你想要的是itertools.product():

from itertools import product

list(product(a, b))
#[(71, 43), (71, 42), (75, 43), (75, 42)]

关于python - 来自单独数组中纬度/经度坐标的(纬度,经度)的所有可能点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24243673/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com