放大Cartopy正投影图

问题描述 投票:0回答:2

我想在正投影一些Cartopy地块放大,但现在看来,这是不可能用简单的方法ax.set_extent()。我正在使用的代码:

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

fig = plt.figure()
ax = plt.axes(projection = ccrs.Orthographic())
ax.set_global()
ax.set_extent((-120,120,50,90), crs = ccrs.PlateCarree())

我收到以下错误:ValueError: Failed to determine the required bounds in projection coordinates.

其实我只需要设置一个下限范围,使极地地区,这是我使用底图之前做的一个情节。但是我不知道怎样与Cartopy进行。

是否有某种方式来做到这一点?

matplotlib orthographic cartopy
2个回答
0
投票

我有想象如何所需Orthograhic投影与限制坐标希望看起来像轻微的问题 - 按说cartopy :-)有了解类似的问题。 当然,你可以使用一个不同的(和可能更合适)投影; LambertConformal可能是有意义的。

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

fig = plt.figure()
proj = ccrs.LambertConformal(central_longitude=-96.0, central_latitude=39.0, )
ax = plt.axes(projection = proj)

ax.set_extent((-120,120,50,90), crs = ccrs.PlateCarree())

ax.coastlines(resolution='110m')
ax.gridlines()
plt.show()

enter image description here


0
投票

这里的问题是,你的经度范围太大,在既不-120或120正字盘以0中心经度/纬度上(他们是“落后”的话)。你可以先查询一下全球经度程度,然后使用,而不是(-120,120)。

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

fig = plt.figure()
ax = plt.axes(projection = ccrs.Orthographic())
ax.set_global()

global_extent = ax.get_extent(crs=ccrs.PlateCarree())
ax.set_extent(global_extent[:2] + (50, 90), crs=ccrs.PlateCarree())
ax.coastlines()

Orthographic projection with limited extent

© www.soinside.com 2019 - 2024. All rights reserved.