Skip to content

Updated scripts for aws-landsat #3

merged 1 commit into from Feb 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Updated scripts for aws-landsat
Amanda Tan committed Feb 8, 2022
commit 281e032c9507fd9c5a26068e2ee92ad15ceb80ad
16 changes: 0 additions & 16 deletions aws-landsat/install_packages.sh

This file was deleted.

12 changes: 9 additions & 3 deletions aws-landsat/process_sat.py
@@ -1,9 +1,10 @@
#!/usr/bin/python3
#!/Users/amandatan/miniconda3/envs/myenv/bin/python
import os
import rasterio
import numpy as np

print('Landsat on AWS:')
filepath = 'http://landsat-pds.s3.amazonaws.com/c1/L8/042/034/LC08_L1TP_042034_20170616_20170629_01_T1/LC08_L1TP_042034_20170616_20170629_01_T1_B4.TIF'
filepath = 'https://landsat-pds.s3.amazonaws.com/c1/L8/042/034/LC08_L1TP_042034_20170616_20170629_01_T1/LC08_L1TP_042034_20170616_20170629_01_T1_B4.TIF'
with rasterio.open(filepath) as src:
print(src.profile)

@@ -18,7 +19,7 @@
print(thumbnail)

date = '2017-06-16'
url = 'http://landsat-pds.s3.amazonaws.com/c1/L8/042/034/LC08_L1TP_042034_20170616_20170629_01_T1/'
url = 'https://landsat-pds.s3.amazonaws.com/c1/L8/042/034/LC08_L1TP_042034_20170616_20170629_01_T1/'
redband = 'LC08_L1TP_042034_20170616_20170629_01_T1_B{}.TIF'.format(4)
nirband = 'LC08_L1TP_042034_20170616_20170629_01_T1_B{}.TIF'.format(5)

@@ -30,6 +31,11 @@
red = src.read(1, out_shape=(1, int(src.height // oview), int(src.width // oview)))
print(red)

with rasterio.open(url+nirband) as src:
oviews = src.overviews(1) # list of overviews from biggest to smallest
oview = oviews[1] # Use second-highest resolution overview
nir = src.read(1, out_shape=(1, int(src.height // oview), int(src.width // oview)))

def calc_ndvi(nir,red):
'''Calculate NDVI from integer arrays'''
nir = nir.astype('f4')