gpt4 book ai didi

python - 如何获取 cartopy 大地测量图的转换数据?

转载 作者:行者123 更新时间:2023-12-01 06:41:18 24 4
gpt4 key购买 nike

如何在以下代码中获取“句柄”- Line2D 对象的转换行的所有数据:

import cartopy.crs as ccrs
import matplotlib.pyplot as plt

ax = plt.axes(projection=ccrs.PlateCarree())
ax.stock_img()

ny_lon, ny_lat = -75, 43
delhi_lon, delhi_lat = 77.23, 28.61

handle = plt.plot([ny_lon, delhi_lon], [ny_lat, delhi_lat],
color='blue', linewidth=2, marker='o',
transform=ccrs.Geodetic(),
)
plt.show()

更清楚地说:我不是在寻找“handle[0].get_data()”的输出,因为这只是打印我原来的经度和纬度,但我在寻找 map 上绘制的大地线的数据。

最佳答案

我找到了答案!据此question ,您可以通过以下代码片段访问转换的数据:

[handle] = plt.plot([ny_lon, delhi_lon], [ny_lat, delhi_lat], color='blue', linewidth=2, marker='o', transform=ccrs.Geodetic())

t_path = handle._get_transformed_path()

path_in_data_coords, _ = t_path.get_transformed_path_and_affine()
print(path_in_data_coords.vertices)

在回答这个问题时,还有第二种方法。

关于python - 如何获取 cartopy 大地测量图的转换数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59445829/

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