首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在Cartopy's LambertConformal中限制经度范围并保持二次曲线外观?

如何在Cartopy's LambertConformal中限制经度范围并保持二次曲线外观?
EN

Stack Overflow用户
提问于 2021-01-13 00:02:57
回答 1查看 348关注 0票数 0

我想制作一个聚焦于欧洲的Lambert Conic图。我可以执行以下操作:

代码语言:javascript
运行
复制
import cartopy.crs as ccrs
import matplotlib.pyplot as plt

proj = ccrs.LambertConformal(central_longitude=20.0, central_latitude=45.0, cutoff=30)
fig = plt.figure(figsize=(10,10))
ax = fig.add_subplot(111, projection=proj)
ax.coastlines(resolution='110m')
plt.show()

然而,这太多地延伸到了东方和西方。我想把它缩小到,比如说,在10W到40E之间。如果我添加一行ax.set_extent([-10,40,30,90], crs=ccrs.PlateCarree()),我会失去上面图中的二次曲线“外观”:

怎样才能适当地减小Cartopy's LambertConformal中的纵向范围,同时仍然保持二次曲线的外观?我可以给出经度边距,让第一个数字在两个子午线之间进行调整,而不是放在这个矩形中吗?我想象两个子午线之间有一个三角形,在纬度较低的地方有一个拱形。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-13 03:34:21

这就是你要找的东西吗?

代码语言:javascript
运行
复制
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import matplotlib.path as mpath

ax = plt.axes(projection=ccrs.LambertConformal(central_longitude=20.0, central_latitude=45.0))
ax.gridlines()
ax.coastlines(resolution='110m')

# Lon and Lat Boundaries
xlim = [-10, 40]
ylim = [30, 90]
lower_space = 10 # this needs to be manually increased if the lower arched is cut off by changing lon and lat lims

rect = mpath.Path([[xlim[0], ylim[0]],
                   [xlim[1], ylim[0]],
                   [xlim[1], ylim[1]],
                   [xlim[0], ylim[1]],
                   [xlim[0], ylim[0]],
                   ]).interpolated(20)

proj_to_data = ccrs.PlateCarree()._as_mpl_transform(ax) - ax.transData
rect_in_target = proj_to_data.transform_path(rect)

ax.set_boundary(rect_in_target)
ax.set_extent([xlim[0], xlim[1], ylim[0] - lower_space, ylim[1]])

改编自this example

输出:

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65687535

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档