Skip to content

Commit

Permalink
Generate and process NDVI image
Browse files Browse the repository at this point in the history
  • Loading branch information
plant99 committed Jul 23, 2020
1 parent 9e79e54 commit e3e677b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions felicette/sat_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@
PIL.Image.MAX_IMAGE_PIXELS = 933120000


def process_landsat_ndvi(id, bands=[4,5]):
band4 = rasterio.open('LC81430542020100-b4.tiff') #red
band5 = rasterio.open('LC81430542020100-b5.tiff') #nir

#generate nir and red objects as arrays in float64 format
red = band4.read(1).astype('float64')
nir = band5.read(1).astype('float64')

ndvi = (nir - red) / (nir+red)
#export ndvi image
ndvi_image = rasterio.open('ndvi.tiff','w',driver='Gtiff',
width=band4.width,
height = band4.height,
count=1, crs=band4.crs,
transform=band4.transform,
dtype='float64')
ndvi_image.write(ndvi,1)
ndvi_image.close()


def process_landsat_data(id, bands=[2, 3, 4]):

# get paths of files related to this id
Expand Down

0 comments on commit e3e677b

Please sign in to comment.