gpt4 book ai didi

python - 定义 cartopy 上墨卡托投影的纵向范围

转载 作者:行者123 更新时间:2023-11-30 22:38:14 25 4
gpt4 key购买 nike

我正在尝试绘制一些以矩阵形式存在的数据,例如温度。这些数据是区域性的,所以我不需要全局 map 。

我有:

  1. 数据矩阵 (mxn)
  2. 定义纬度 (mx1) 和经度 (nx1) 的向量

我想使用带有墨卡托投影的 cartopy 来绘制它。然而,墨卡托只允许我定义最小和最大纬度,但不能定义最小和最大经度。这最终给了我一大片土地。

Mercator(central_longitude=103.0,min_latitude=gridlat[0],max_latitude=gridlat[-1])

我将如何设置沿海 map 的最小和最大经度?最终,我只想绘制我的数据,并在其上覆盖国家/地区边界,就像使用 ncview 的外观一样。

最佳答案

在选择投影时,您通常不会设置 map 的范围,您可以稍后使用您创建的坐标区的 set_extent 方法进行设置。事实上,cartopy 中的默认行为是使范围适合绘制的数据,因此您想要的应该是使用普通墨卡托投影绘制绘图时发生的情况。以下是在地理坐标中显式设置范围的示例:

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

# Create Mercator projection with dateline in the middle:
ax = plt.axes(projection=ccrs.Mercator(central_longitude=180))
# Draw coastlines so we know where we are:
ax.coastlines()
# Set the map extent, making sure to specify the correct coordinate system
# for geographical coordinates:
ax.set_extent([90, 270, -40, 40], crs=ccrs.PlateCarree())
plt.show()

关于python - 定义 cartopy 上墨卡托投影的纵向范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43647548/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com