如何限制 Cartopy 的 LambertConformal 中的经度范围并保持圆锥形外观?

问题描述

我想制作一个专注于欧洲的兰伯特圆锥曲线。我可以执行以下操作:

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()

enter image description here

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

enter image description here

如何在 cartopy 的 LAmbertConformal 中适当地减小纵向范围,同时仍然保持圆锥外观?我可以给经度边距并在两条子午线之间调整第一个数字,而不是把它放在这个矩形中吗?我想象两条经线之间的三角形形状,以及纬度下限处的拱形。

解决方法

这是您要找的吗?

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[1]],[xlim[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

输出:

Lambert Conic plot focused on Europe

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...