Wetland extent data was obtained from the Oakland Ridge National Laboratory Distributed Active Archive Centre (Hess et al., 2015). The raster was cropped to along the middle-lower Amazon River and resampled to the inundation frequency (IF) raster’s resolution. The raster contains information on wetland cover during both low-water and high-water stage in the Amazon, but because the IF-depth model is calibrated using survey data collected during the flooding season, the high-water stage wetland data was used to mask the IF data. For detailed code on how the raster was processed using rasterio and rioxarray, please refer to this repository.
Code
import numpy as npimport matplotlib.pyplot as pltimport rasterio as riofrom matplotlib.patches import Patchfrom matplotlib.colors import ListedColormap# Import wetland extentwetland = rio.open("../data/wetland_nearest.tif")# Read into a NumPy array (only 1 band)wetland_np = wetland.read(1)# Group values into categorieswetland_group = np.zeros_like(wetland_np) # Initialize grouped arraywetland_group[wetland_np ==1] =0# Backgroundwetland_group[(wetland_np ==11) | (wetland_np ==21) | (wetland_np ==41)| (wetland_np ==51)] =1# Open waterwetland_group[(wetland_np ==13) | (wetland_np ==23) | (wetland_np ==33)] =2# Macrophytewetland_group[(wetland_np ==44) | (wetland_np ==66)] =3# Non-flooded shrub/ woodlandwetland_group[(wetland_np ==45) | (wetland_np ==55)] =4# Flooded shrubwetland_group[(wetland_np ==67) | (wetland_np ==77)] =5# Flooded woodlandwetland_group[(wetland_np ==88)] =6# Non-flooded forestwetland_group[(wetland_np ==89) | (wetland_np ==99)] =7# Flooded forest# Custome palettecustom_colors = ['#000000','#2559DE', '#E432BF', '#EE8761', '#97EBD9', '#A0C0FF', '#FFFF00', '#59A52F']cmap = ListedColormap(custom_colors) # Create a discrete colormap# Custom labelslabels = ["","Open water","Macrophyte","Non-flooded shrub/ woodland","Flooded shrub","Flooded woodland","Non-flooded forest","Flooded forest"]# Plotfig, ax = plt.subplots(figsize=(10, 4))img = ax.imshow(wetland_group, cmap=cmap)# Set background to beigefig.patch.set_facecolor("#F9F8F2")ax.set_facecolor("#F9F8F2")# Add a discrete legendlegend_patches = [Patch(color=custom_colors[i], label=labels[i]) for i inrange(len(labels))]legend = ax.legend( handles=legend_patches, loc='lower right', bbox_to_anchor=(1.0, 0.05), frameon=False, # No frame fontsize=8, ncol=2, # Split into 2 columns columnspacing=1.2, # Space between columns labelcolor='white'# White text)# Remove axes for clean aestheticsax.axis("off")
Figure 1: Wetland extent during high-water stage
The vegetation cover in the middle-lower Amazon is diverse, ranging from aquatic macrophytes (herbaceous plants) that grow in or near the water, to forests that are annually submerged under water.