I am trying to follow a tutorial for computing NDVI (Normalized Difference Vegetation Index) through the
rasterio package in python, however, I am unsure how to finish the task by actually creating the raster
.tif file itself. I am following this tutorial here: https://automating-gis-processes.github.io/CSC18/lessons/L6/raster-calculations.html
from Henrikki Tenkanen.
I follow the tutorial all the way until the end and then am left with
ndvi which I can see is an array, and I can find its mean and also plot/map it like shown in the tutorial. However, how do I actually convert this object/array to a raster .tif file that I can actually view in QGIS? It seems like that step is missing from the tutorial.
Just looking through rasterio documentation, it seems like there is some need to use a
dst.write() argument, but I am just too new at this to really understand how to actually use this process. It looks something like:
with rasterio.open('example.tif', 'w', **profile) as dst: dst.write(array.astype(rasterio.uint8), 1)
Here is the
dst.write() documentation I got this from: https://rasterio.readthedocs.io/en/latest/topics/writing.html
I cannot figure out how to send
ndvi to a .tif raster with the correct syntax. How can I complete this tutorial so that an actual ndvi raster
.tif file is created? I am confused by what the kwargs are and how to use them.