The visualization depicts a classified map distinguishing intact dense forest areas (dark green) from regions of dead or removed forest cover (lighter shades) within the domain of study. To enhance analytical interpretation, we leverage the EarthPy Python package to transform the continuous Normalized Difference Vegetation Index (NDVI) spectral index into binned categories. EarthPy facilitates straightforward plotting and analysis of remote sensing imagery bands. Here, it enables flexible visualization of the gradient of vegetated conditions derived from the NDVI ranges computed across the Sentinel-2 scene. Quantitative thresholds divide the index values into categorizations interpretable as grades of forest health and disturbance. Translating the continuous imagery into discrete thematic classes in this way simplifies identification of regions undergoing ecological transitions of interest. Over time, aggregation of NDVI-based forest change classifications produced using open access tools like EarthPy can feed indicators to guide reforestation interventions or quantify habitat conservation successes.
# Create classes and apply to NDVI resultsndvi_class_bins = [-np.inf, 0, 0.1, 0.25, 0.4, np.inf]
ndvi_density_class = np.digitize(ndvisample, ndvi_class_bins)
# Apply the nodata mask to the newly classified NDVI data
ndvi_density_class = np.ma.masked_where(
    np.ma.getmask(ndvisample), ndvi_density_class
)
np.unique(ndvi_density_class)
from matplotlib.colors import ListedColormap# Define color map
nbr_colors = ["khaki", "y", "yellowgreen", "g", "darkgreen"]
nbr_cmap = ListedColormap(nbr_colors)
# Define class names
ndvi_cat_names = [
    "Dead forest",
    "Scrub",
    "Open Forest",
    "Moderately Dense Forest",
    "Very Dense Forest",
]
# Get list of classes
classes = np.unique(ndvi_density_class)
classes = classes.tolist()
# The mask returns a value of none in the classes. remove that
classes = classes[0:5]
# Plot your data
fig, (ax1) = plt.subplots(1, figsize=(12, 12), num=1, clear=True)
im1 = ax1.imshow(np.squeeze(ndvi_density_class), cmap=nbr_cmap)
ep.draw_legend(im_ax=im1, classes=classes, titles=ndvi_cat_names)
ax1.set_title(
    "Sentinel2 - Normalized Difference Vegetation Index (NDVI) Classes",
    fontsize=14,
)
ax1.set_axis_off()
plt.tight_layout()