The code below gives me an error telling me:
File "/home/ludo915/Eco-Tech H2GAM/maps.py", line 242, in compute_maps
a.add_geometries(countryEU['F'].polygon, ccrs.PlateCarree(),
TypeError: 'NaturalEarth_v5_0_0' object is not subscriptable
fig = plt.figure(figsize=(8,8))
gs = fig.add_gridspec(1, 1)
ax1 = fig.add_subplot(gs[0, 0], projection=ccrs.PlateCarree())
axes = [ax1]
ax1.background_patch.set_fill(False)
for a in axes:
a.add_geometries(countryEU['F'].polygon, ccrs.PlateCarree(),
edgecolor=grayDark, lw=2, facecolor=grayDark, alpha=0.6, zorder=0)
a.set_extent([-5,10,41,52])
a.set_aspect('auto')
a.outline_patch.set_linewidth(0.)
pass
My script worked perfectly before the migration to V5_0_0 of NaturalEarth. Any ideas?
Post transferred to https://github.com/nvkelso/natural-earth-vector/issues/884
Asked for an update on stackoverflow.
This works now but the greyscale enlightenin foreground no longer fits the map correctly any ideas?
fig = plt.figure(figsize=(8,8))
gs = fig.add_gridspec(1, 1)
ax1 = fig.add_subplot(gs[0, 0], projection=ccrs.PlateCarree())
axes = [ax1]
ax1.background_patch.set_fill(False)
for a in axes:
a.add_geometries([regionmask.defined_regions.prudence["FR"].polygon,], ccrs.PlateCarree(),
edgecolor=grayDark, lw=2, facecolor=grayDark, alpha=0.6, zorder=0)
a.set_extent([-5,10,41,52])
a.set_aspect('auto')
a.outline_patch.set_linewidth(0.)
pass
cax = ax1.scatter(risk1Maps[counter].lon,risk1Maps[counter].lat,c=risk1Maps[counter].idx,
cmap='RdYlGn_r', s=markersize*5, vmin=0, vmax=risk1max, zorder=4)
cbar = fig.colorbar(cax, orientation='horizontal', pad=0, aspect=50,
fraction=.01, extend='max', drawedges=False, ticks=[0, risk1max])
cbar.ax.set_xticklabels(['low', 'high'])
cbar.ax.xaxis.set_ticks_position('top')
cbar.ax.xaxis.set_label_position('top')
ax1.text(0,.0,'Data \nCAMS \ndata.gouv.fr', transform=ax1.transAxes,fontdict={'size':12})
currentDateWD = today.strftime('%a, %d - %m, %Y')
ax1.set_title('PM2.5 concentrations: \n{:}\n'.format(currentDateWD + " + "+ str (counter) + " days"),
loc='left', pad=-60)
fig.subplots_adjust(bottom=.01, left=.01, right=.99, top=.99)
#plt.show()
buffer = io.BytesIO()
plt.savefig(buffer, format='png', dpi=70)
buffer.seek(0)
images1.append(imageio.imread(buffer))
buffer.close()
plt.close()
Ludo
