Skip to main content
100%

Gist 6030672

✓ Published0🌍 Public
Aapburnes
Last edited Nov 3, 2011
Created on Jul 18, 2013

This example computes the Normalized Difference Vegetation Index (NDVI) from red and near-infrared raster bands, then writes the result as a single-band GeoTIFF. It uses the GDAL Python API via `gdal.Open`, `ReadAsArray`, `GetGeoTransform`, and `GetProjectionRef` to read input data and preserve spatial metadata. The calculation applies `np.logical_and` and `np.where` to mask invalid pixels, setting them to -999, while `save_raster` creates the output with LZW compression and tiling. The code handles format selection through a `driver` parameter, defaulting to GeoTIFF.

AI-generated description

Similar vizzes