cartopy:更高分辨率的大圆距离线

问题描述 投票:0回答:1

我正在尝试绘制两点之间的大圆距离。我在 cartopy 文档中找到了一个(introductory_examples/01.great_circle.html):

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

ax = plt.axes(projection=ccrs.Robinson())

ax.set_global()

ax.coastlines()

plt.plot([-0.08, 132], [51.53, 43.17], color='red',      transform=ccrs.Geodetic())
plt.plot([-0.08, 132], [51.53, 43.17], color='blue', transform=ccrs.PlateCarree())

plt.show()

生成以下图像:

great circle example

问题是,在我自己的工作中,这两点更加接近,并且在不同的投影中(尽管我认为这在这里并不重要)。如果我将此代码更改为较小区域中的一行,如下所示:

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

ax = plt.axes(projection=ccrs.Robinson())

ax.set_extent([-5, 55, 40, 55])

ax.coastlines()

plt.plot([-0.08, 50], [51.53, 43.17], color='red',      transform=ccrs.Geodetic())
plt.plot([-0.08, 50], [51.53, 43.17], color='blue', transform=ccrs.PlateCarree())

plt.show()

这会产生以下图像:

shorter line

这种情况下的红色大圆线看起来很糟糕,看起来是由于分辨率太低造成的。如何增加构成大圆线的点数?

python matplotlib cartopy
1个回答
12
投票

这个问题是由于投影中的硬编码阈值造成的。目前这不是用户可控的参数,但您可以通过定义自己的子类来解决这个问题:

class LowerThresholdRobinson(ccrs.Robinson):

    @property
    def threshold(self):
        return 1e3

如果在定义轴时使用

LowerThresholdRobinson()
而不是
ccrs.Robinson()
,这应该可以消除问题。

© www.soinside.com 2019 - 2024. All rights reserved.