【问题标题】:cartopy: higher resolution for great circle distance linecartopy:大圆距离线的分辨率更高
【发布时间】:2017-03-09 08:00:57
【问题描述】:

我试图在两点之间绘制一个很大的圆距离。我在 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】:

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

    class LowerThresholdRobinson(ccrs.Robinson):
    
        @property
        def threshold(self):
            return 1e3
    

    如果在定义轴时使用LowerThresholdRobinson() 而不是ccrs.Robinson(),这应该可以消除问题。

    【讨论】:

    • 尝试此解决方法时出现错误。 ValueError: Image size of 319440347x319385677 pixels is too large. It must be less than 2^16 in each direction 使用 Python 3.7.2 和 Cartopy 0.17.0。有什么想法吗?
    • 我尝试将它与 PlateCarree 一起使用 - 摆弄阈值要么使“steppiness”变得更糟,要么这条线变成一条直线
    • PlateCarree 的默认阈值要小得多,为全局图的 0.5。您是否尝试过小于 0.5 的值?
    • 我无法让它工作,但 KiwiKilian 的链接很有效
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-07-24
    • 2018-01-17
    • 1970-01-01
    • 1970-01-01
    • 2012-07-27
    • 1970-01-01
    • 2016-04-22
    相关资源
    最近更新 更多