Reputation: 1
I am trying to plot PM data in lat lon pairs data using cartopy. 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):
a) Why do the colors in Albera Equal Area conic projection look smoother?
b) How do I add state borders in conic area projection?
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)
Upvotes: 0
Views: 475
Reputation: 846
a) I think Albers looks smoother maybe just because the projection is different, the figure of projection Plate Carre is squashed into a band.
b) You should set the axes projection firstly just like in Plate Carre plot, then shapefile polygons will show in the figure.
fig = plt.figure(figsize=(8,4))
projection = ccrs.AlbersEqualArea(central_longitude=-100)
ax = plt.axes(projection=projection)
ax.add_feature(...)
ax.add_feature(...)
....
Upvotes: 0