简体   繁体   English

如何在阿尔贝拉等面积投影中使用经纬度对在 cartopy 中进行 plot?

[英]How to plot in Albera Equal area projection using lat lon pairs in cartopy?

I am trying to plot PM data in lat lon pairs data using cartopy.我正在尝试使用 cartopy 对纬度对数据中的 plot PM 数据进行处理。 I tried it using two different projections.我使用两种不同的投影进行了尝试。 (PM25['lat'] has lat values, PM25['lon'] has lon values and val is the grid with PM25 concentrations): (PM25['lat'] 有 lat 值,PM25['lon'] 有 lon 值,val 是 PM25 浓度的网格):

  1. Plate Carre and 2. Albera Equal Area Conic projection.板 Carre 和 2。Albera 等面积圆锥投影。 I am attaching the code and figures here.我在这里附上代码和数字。 My questions are我的问题是

a) Why do the colors in Albera Equal Area conic projection look smoother? a) 为什么Albera等面积圆锥投影中的colors看起来更平滑?

b) How do I add state borders in conic area projection? b) 如何在圆锥区域投影中添加 state 边界?

Code for Albera Projection阿尔贝拉投影代码

extent = [-125,-65,25,50]
fig = plt.figure(figsize=(8,4))
ax.set_extent(extent)
ax.coastlines(resolution="110m",linewidth=1)
ax.gridlines(linestyle='--',color='black')
ax.add_feature(cfeature.BORDERS.with_scale('50m'), alpha=1)
ax.add_feature(cfeature.STATES)
projection = ccrs.AlbersEqualArea(central_longitude=-100)
ax.add_feature(COUNTIES, facecolor='none', edgecolor='gray', alpha =0.5)
projection = ccrs.AlbersEqualArea(central_longitude=-100)
fig.add_axes([-.05, -.05, 1.2, 1.2], projection=projection)
ax.add_feature(cfeature.STATES)[enter image description here][1]
clevs = np.arange(0,40)
plt.contourf(PM25['lon'], PM25['lat'], val,clevs, transform=ccrs.PlateCarree(),cmap='viridis',vmin=0, 
vmax =16)

Albera Equal Area Conic Projection阿尔贝拉等面积圆锥投影

Code for Plate Carre Projection板卡雷投影代码

from matplotlib import colorbar, colors
extent = [-125,-65,25,50]
fig = plt.figure(figsize=(8,4))
ax = plt.axes(projection=ccrs.PlateCarree())
ax.set_extent(extent)
ax.coastlines(resolution="110m",linewidth=1)
ax.gridlines(linestyle='--',color='black')
ax.add_feature(cfeature.BORDERS.with_scale('50m'), alpha=1)
ax.add_feature(cfeature.STATES)
#ax.add_feature(COUNTIES, facecolor='none', edgecolor='gray', alpha =0.5)
clevs = np.arange(0,40)
plt.contourf(PM25['lon'], PM25['lat'], val,clevs, transform=ccrs.PlateCarree(),cmap='viridis',vmin=0, 
 vmax =16)

Plate Carre Projection板卡雷投影

a) I think Albers looks smoother maybe just because the projection is different, the figure of projection Plate Carre is squashed into a band. a) 我觉得 Albers 看起来更平滑可能只是因为投影不同,投影 Plate Carre 的图形被压成带状。

b) You should set the axes projection firstly just like in Plate Carre plot, then shapefile polygons will show in the figure. b) 您应该首先设置轴投影,就像在Plate Carre plot 中一样,然后 shapefile 多边形将显示在图中。

fig = plt.figure(figsize=(8,4))
projection = ccrs.AlbersEqualArea(central_longitude=-100)
ax = plt.axes(projection=projection)
ax.add_feature(...)
ax.add_feature(...)
....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM