Since the recent post, where I only included True Color Imagery using Sentinel-2 data, providing an overview of some major cities, I thought it might also be interesting to extend those examples so we can have a look at the vegetation around (and also inside) of the cities.
We can use a simple Normalized Difference Vegetation Index (NDVI) that is computed like so:
$$ NDVI = \frac{NIR - RED}{NIR + RED} $$
The only things that change from our previous example’s code would be that instead of selecting the RGB bands from the STAC Catalog using stackstac, we only select the NIR
and RED
bands. This corresponds to the B08
and B04
Sentinel-2 bands:
|
|
After that, we perform the cropping of the cube to our desired Area of Interest, we can separate the two bands using xarray.sel()
|
|
Then, we compute NDVI:
|
|
So, our ndvi
cube ends up looking like this:
By using dask and geogif we can create GIF’s of the vegetation presence throughout the years: