1
votes

I'm trying to zoom in some Cartopy plots in Orthographic projection, but it seems it is not possible with the simple ax.set_extent() method. The code I'm using:

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

I receive the following error: ValueError: Failed to determine the required bounds in projection coordinates.

Actually I'd only need to set a lower boundary latitude to make a plot of the polar region, which I used to do before with Basemap. However I do not see how to proceed with Cartopy.

Is there some way to do this?

2

2 Answers

1
votes

The problem here is that your longitude extent is too big, in that neither -120 or 120 are on the orthographic disk with central longitude/latitude of 0 (they are "behind" it). You could first query what the global longitude extent is then use that instead of (-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

0
votes

I do have slight problems imagining how the desired Orthograhic projection with the restricted coordinates is desired to look like - and supposedly cartopy has similar issues of understanding :-).
But of course you can use a different (and potentially more suitable) projection; LambertConformal may make sense.

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