This repository shows how to calculate the Normalized Difference Water Index (NDWI) using Landsat 5 data.
Satellite image of the province of Bursa was used for this study.
- Product Type: LANDSAT_5_TM_L1TP
- Sensing Time: 27-JUL-2006 08:38:59.842000
The following libraries were used while writing the Python code;
- Earthpy
- Rasterio
- Numpy
- Matplotlib
Landsat 5 input image (a tiff file) call with related library. Then, names of bands assign from test image as green and nir. With given code, the process continue.
ndwi = es.normalized_diff(green, nir)
NDWI is used to monitor changes in water content in water bodies. As water bodies absorb light strongly in the visible infrared electromagnetic spectrum, NDWI uses green and near infrared bands to highlight water bodies. The index was proposed by 1996 McFeeters.
- In Landsat 5, NDWI = (Band 2 – Band 4) / (Band 2 + Band 4).
After display settings, output as shown:
At this stage, the output image call with this code as a single band
meta = image.profile
meta.update(driver='GTiff')
meta.update(count= 1)
with rasterio.open('NDWI.tif', 'w', **meta) as file:
file.write(ndwi, 1)
file.close()
If the created tiff file is opened with the help of the software, the following image is obtained:
Analysis can be made about the water with the resulting image. In this image, the waters appear as bright, other areas appear as dark areas.