You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用ccrs.SouthPolarStereo绘制南极地图异常及冰架填充问题求助

解决南极地图异常显示及冰架填充问题

一、修复异常图形

你的代码出现异常图形,核心原因是绘图内容未被圆形边界裁剪,可通过以下调整解决:

  • 调整边界设置顺序并开启裁剪功能
    将圆形边界的代码移至contourf绘图之前,同时开启坐标轴裁剪,确保后续绘制内容被边界限制:

    ax = fig.add_subplot(gs[0], projection=ccrs.SouthPolarStereo())
    # 先设置圆形边界
    theta = np.linspace(0, 2*np.pi, 100)
    center, radius = [0.5, 0.5], 0.5
    verts = np.vstack([np.sin(theta), np.cos(theta)]).T
    circle = mpath.Path(verts * radius + center)
    ax.set_boundary(circle, transform=ax.transAxes)
    # 开启裁剪属性
    ax.set_clip_on(True)
    
    # 再绘制数据层,移除冗余的transform_first参数
    ax.set_extent([-180, 180, -90, -40], ccrs.PlateCarree())
    ax.contourf(lon, lat, ncp, levels=np.linspace(0,60,51),
                extend='max', cmap=cmaps.WhiteBlueGreenYellowRed,
                transform=ccrs.PlateCarree())
    
  • 验证投影匹配
    确保lon、lat为标准经纬度坐标,与transform=ccrs.PlateCarree()参数完全匹配,避免因投影错位导致图形异常。

二、填充冰架区域为灰色

需要借助南极冰架的矢量数据(如NSIDC发布的冰架shapefile),实现步骤如下:

  1. 准备冰架数据
    获取南极冰架的shapefile文件(可从极地数据机构下载),假设文件路径为antarctic_ice_shelves.shp。

  2. 读取并绘制冰架
    使用geopandas读取数据并转换投影后,添加到地图坐标轴:

    import geopandas as gpd
    
    # 读取冰架矢量数据
    ice_shelves = gpd.read_file('antarctic_ice_shelves.shp')
    # 转换为南极极射投影
    ice_shelves_proj = ice_shelves.to_crs(ccrs.SouthPolarStereo().proj4_init)
    # 填充灰色,可自定义边缘样式
    ax.add_geometries(ice_shelves_proj.geometry, crs=ccrs.SouthPolarStereo(),
                      facecolor='gray', edgecolor='darkgray', linewidth=0.3, zorder=1)
    

    注:设置zorder=1可确保冰架层位于数据层下方,避免覆盖contourf绘制的内容。

内容的提问来源于stack exchange,提问作者Auroralin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 07:26:24