【问题标题】:Location of background image incorrect using Cartopy for the Moon使用 Cartopy for Moon 时背景图像的位置不正确
【发布时间】:2023-02-06 01:58:29
【问题描述】:

我正在尝试在 AzimuthalEquidistant 投影中绘制一张月球地图,其中一个点位于 Mare Orientale 的纬度/经度。当我尝试这样做时,标绘点就在 Orientale 正上方,但投影应该以它为中心。

我从这里得到了背景图片:https://astrogeology.usgs.gov/search/map/Moon/LRO/LROC_WAC/Lunar_LRO_LROC-WAC_Mosaic_global_100m_June2013 我相信它在 PlateCarree 投影中。

olat = -19.8304 
olon = 264.757

moon = ccrs.Globe(semimajor_axis=1738100, semiminor_axis=1738100, ellipse=None)
pc = ccrs.PlateCarree(globe=moon)
ae = ccrs.AzimuthalEquidistant(olon, olat, globe=moon)

fig = plt.figure()
ax = plt.subplot(111, projection=ae)
bg = Image.open('moon2.jpeg')
plt.imshow(bg, extent=(-180,180,-90,90), transform=pc)
gl = ax.scatter(olon, olat, transform=pc)
ax.set_global()
plt.show()

然而,在 PlateCarree 投影中绘制所有内容,点和 Orientale 完美对齐

我重新定义了 Cartopy 用作月球椭圆体的地球仪,这没有任何区别,而且我知道纬度/经度是正确的,因为在使用 PlateCarree 投影时一切都对齐。

【问题讨论】:

    标签: python-3.x matplotlib maps cartopy


    【解决方案1】:

    由于您的代码不完整,我必须使用自己的代码来弥补缺失的部分。 完整代码如下。

    import matplotlib.pyplot as plt
    import cartopy.crs as ccrs
    
    olat = -19.8304 
    olon = 264.757
    
    moon = ccrs.Globe(semimajor_axis=1738100, semiminor_axis=1738100, ellipse=None)
    pc = ccrs.PlateCarree(globe=moon)
    ae = ccrs.AzimuthalEquidistant(olon, olat, globe=moon)
    
    fig = plt.figure()
    ax = plt.subplot(111, projection=ae)
    
    image = plt.imread('./images/Moon_LRO_LROC-WAC_Mosaic_global_1024.jpg')
    
    ax.imshow(image, extent=(-180,180,-90,90), transform=pc)
    
    gl = ax.scatter(olon, olat, color="red", transform=pc)
    ax.set_global()
    plt.show()
    

    现在输出似乎没问题。因此,您的代码行:

    plt.imshow(image, extent=(-180,180,-90,90), transform=pc)
    

    是错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多