cartopy - AlbersEqualArea limit region using lon and lat

 ̄綄美尐妖づ 提交于 2019-12-08 01:01:41

问题


I have data which is -100o - 30o lon and 0o - 80o lat.

I would like to use a projection to only show this region.

In my head I would like to show a plot like this:

However, when I try the AlbersEqualArea projection as follows:

plt.figure(figsize=(5.12985642927, 3))
ax = plt.axes(projection=ccrs.AlbersEqualArea(central_longitude=-35, central_latitude=40, standard_parallels=(0, 80)))    
ax.set_extent([lon180[0], lon180[-1], lat[0], lat[-1]], ccrs.Geodetic())

I get a map showing:

What is the best way to show the area that I have data for?

Cheers, Ray


回答1:


If you want to have a non-rectangular boundary you'll have to define it yourself. Something like the following may work for you:

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

proj = ccrs.AlbersEqualArea(central_longitude=-35,
                            central_latitude=40,
                            standard_parallels=(0, 80))
ax = plt.axes(projection=proj)    
ax.set_extent([-100, 30, 0, 80], crs=ccrs.PlateCarree())
ax.coastlines()

# Make a boundary path in PlateCarree projection, I choose to start in
# the bottom left and go round anticlockwise, creating a boundary point
# every 1 degree so that the result is smooth:
vertices = [(lon, 0) for lon in range(-100, 31, 1)] + \
           [(lon, 80) for lon in range(30, -101, -1)]
boundary = mpath.Path(vertices)
ax.set_boundary(boundary, transform=ccrs.PlateCarree())

plt.show()




回答2:


I think maybe you would need to add AlbersEqualArea as a transform on the plot, maybe more like this.



来源:https://stackoverflow.com/questions/43463643/cartopy-albersequalarea-limit-region-using-lon-and-lat

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!