我一直在写一些代码在另外两个点之间画两条线。我想得到坐标,它们的交点在哪里
lat1a = 49.9
lon1a = 22.5
lat1b = -20.2
lon1b = 11.99
lat2a = -51.5
lon2a = -68
lat2b = -8.04
lon2b = 14.6
land_50m = cfeature.NaturalEarthFeature('physical', 'land', '50m',
edgecolor='face',
facecolor=cfeature.COLORS['land'])
ax = plt.axes(projection=ccrs.Robinson())
ax.set_extent([-90, 50, -60, 70])
ax.add_feature(cfeature.COASTLINE)
ax.add_feature(cfeature.BORDERS, linewidth=0.2)
ax.plot(22.5, 49.2, marker='s', color='black', markersize=7, transform=ccrs.Geodetic())
ax.plot(-69.3, -51.5, marker='s', color='black', markersize=7, transform=ccrs.Geodetic())
ax.plot([lon2b, lon2a], [lat2b, lat2a], color='b', linestyle='--', transform=ccrs.Geodetic())
ax.plot(lon2b, lat2b, marker='o', color='red', markersize=5, transform=ccrs.Geodetic())
ax.plot([lon1b, lon1a], [lat1b, lat1a], color='b', linestyle='--', transform=ccrs.Geodetic())
ax.plot(lon1b, lat1b, marker='o', color='black', markersize=5, transform=ccrs.Geodetic())
plt.show()
结果呢
我想得到一个坐标列表,在蓝色虚线内,只需在两个列表中寻找重复,这样我就可以区分交叉点,但我一直停留在这一部分。也许你还有别的想法
要获得您想要的(Cartopy+shapely的交点)需要一些复杂的编码,正如您在提供的代码中所看到的那样。如果您只需要
list of coordinates ...
,请查看bpath[0].vertices
工作守则:
输出:
相关问题 更多 >
编程相关推荐