【发布时间】:2021-09-19 14:30:35
【问题描述】:
我有一个带有一些点的 cartopy GeoAxesSubplot,可能还有线或多边形。投影可以是 cartopy 支持的任何投影,包括正交投影。
我可以使用不同的转换进行绘图,如 here 所述:
from matplotlib import pyplot as plt
import cartopy.crs as ccrs
# Projection could be any, e.g. globe or Arctic Stereopolar...
ax = plt.axes(projection=ccrs.Mollweide())
ax.coastlines()
# Plot using the coordinate system of the Axes
a = ax.plot(0.45, 0.5, transform=ax.transAxes, marker='o', ms=10)
# Plot using the projected coordinates using cartopy.crs
b = ax.plot(0, 0, transform=ccrs.PlateCarree() , marker='o', ms=10)
我想转换地理坐标以获取对象在轴上的笛卡尔坐标(例如子图)。即图中坐标轴[0,1]范围内的坐标,(0,0)在左下角,(1,1)在右上角。
在上述情况下,b 应转换为 (0.5, 0, 5),因为它位于地图的中心。
可以使用transform_points 完成类似的操作,但是我无法转置为axes-coords。
在 matplotlib 和 cartopy 中定义了许多参数来控制对象在地图上的位置(范围、投影、中心子午线、视图高度等)。因此,引入另一个库可能会很尴尬。
给出的答案,例如here 解释了如何实现反向,但是,该示例没有给出如何生成轴坐标的正确答案。
【问题讨论】:
标签: python matplotlib transform cartopy