|
|
|
@ -48,17 +48,17 @@ def download_tif(image, polygon, bandsId, filepath):
|
|
|
|
|
# select collection
|
|
|
|
|
input_col = ee.ImageCollection('LANDSAT/LC08/C01/T1_RT_TOA')
|
|
|
|
|
# location (Narrabeen-Collaroy beach)
|
|
|
|
|
#polygon = [[[151.301454, -33.700754],
|
|
|
|
|
# [151.311453, -33.702075],
|
|
|
|
|
# [151.307237, -33.739761],
|
|
|
|
|
# [151.294220, -33.736329],
|
|
|
|
|
# [151.301454, -33.700754]]];
|
|
|
|
|
polygon = [[[151.301454, -33.700754],
|
|
|
|
|
[151.311453, -33.702075],
|
|
|
|
|
[151.307237, -33.739761],
|
|
|
|
|
[151.294220, -33.736329],
|
|
|
|
|
[151.301454, -33.700754]]];
|
|
|
|
|
# location (Oldbar beach)
|
|
|
|
|
polygon = [[[152.664508, -31.896163],
|
|
|
|
|
[152.665827, -31.897112],
|
|
|
|
|
[152.631516, -31.924846],
|
|
|
|
|
[152.629285, -31.923362],
|
|
|
|
|
[152.664508, -31.896163]]]
|
|
|
|
|
#polygon = [[[152.664508, -31.896163],
|
|
|
|
|
# [152.665827, -31.897112],
|
|
|
|
|
# [152.631516, -31.924846],
|
|
|
|
|
# [152.629285, -31.923362],
|
|
|
|
|
# [152.664508, -31.896163]]]
|
|
|
|
|
# location (Oldbar inlet)
|
|
|
|
|
#polygon = [[[152.676283, -31.866784],
|
|
|
|
|
# [152.709174, -31.869993],
|
|
|
|
@ -68,17 +68,17 @@ polygon = [[[152.664508, -31.896163],
|
|
|
|
|
|
|
|
|
|
# dates
|
|
|
|
|
start_date = '2013-01-01'
|
|
|
|
|
end_date = '2018-12-31'
|
|
|
|
|
end_date = '2018-03-25'
|
|
|
|
|
# filter by location
|
|
|
|
|
flt_col = input_col.filterBounds(ee.Geometry.Polygon(polygon))#.filterDate(start_date, end_date)
|
|
|
|
|
flt_col = input_col.filterBounds(ee.Geometry.Polygon(polygon)).filterDate(start_date, end_date)
|
|
|
|
|
|
|
|
|
|
n_img = flt_col.size().getInfo()
|
|
|
|
|
print('Number of images covering the area:', n_img)
|
|
|
|
|
im_all = flt_col.getInfo().get('features')
|
|
|
|
|
|
|
|
|
|
satname = 'L8'
|
|
|
|
|
#sitename = 'NARRA'
|
|
|
|
|
sitename = 'OLDBAR'
|
|
|
|
|
sitename = 'NARRA'
|
|
|
|
|
#sitename = 'OLDBAR'
|
|
|
|
|
suffix = '.tif'
|
|
|
|
|
filepath = os.path.join(os.getcwd(), 'data', satname, sitename)
|
|
|
|
|
filepath_pan = os.path.join(filepath, 'pan')
|
|
|
|
@ -87,6 +87,7 @@ filepath_ms = os.path.join(filepath, 'ms')
|
|
|
|
|
all_names_pan = []
|
|
|
|
|
all_names_ms = []
|
|
|
|
|
timestamps = []
|
|
|
|
|
acc_georef = []
|
|
|
|
|
# loop through all images
|
|
|
|
|
for i in range(n_img):
|
|
|
|
|
# find each image in ee database
|
|
|
|
@ -98,6 +99,7 @@ for i in range(n_img):
|
|
|
|
|
im_timestamp = datetime.fromtimestamp(t/1000, tz=pytz.utc)
|
|
|
|
|
timestamps.append(im_timestamp)
|
|
|
|
|
im_epsg = int(im_dic['bands'][0]['crs'][5:])
|
|
|
|
|
acc_georef.append(im_dic['properties']['GEOMETRIC_RMSE_MODEL'])
|
|
|
|
|
|
|
|
|
|
# delete dimensions key from dictionnary, otherwise the entire image is extracted
|
|
|
|
|
for j in range(len(im_bands)): del im_bands[j]['dimensions']
|
|
|
|
@ -113,14 +115,15 @@ for i in range(n_img):
|
|
|
|
|
filename_ms = satname + '_' + sitename + '_' + im_date + '_ms' + '_r' + suffix
|
|
|
|
|
all_names_pan.append(filename_pan)
|
|
|
|
|
|
|
|
|
|
local_data_pan = download_tif(im, polygon, pan_band, filepath_pan)
|
|
|
|
|
os.rename(local_data_pan, os.path.join(filepath_pan, filename_pan))
|
|
|
|
|
local_data_ms = download_tif(im, polygon, ms_bands, filepath_ms)
|
|
|
|
|
os.rename(local_data_ms, os.path.join(filepath_ms, filename_ms))
|
|
|
|
|
# local_data_pan = download_tif(im, polygon, pan_band, filepath_pan)
|
|
|
|
|
# os.rename(local_data_pan, os.path.join(filepath_pan, filename_pan))
|
|
|
|
|
# local_data_ms = download_tif(im, polygon, ms_bands, filepath_ms)
|
|
|
|
|
# os.rename(local_data_ms, os.path.join(filepath_ms, filename_ms))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open(os.path.join(filepath, sitename + '_timestamps' + '.pkl'), 'wb') as f:
|
|
|
|
|
pickle.dump(timestamps, f)
|
|
|
|
|
with open(os.path.join(filepath, sitename + '_epsgcode' + '.pkl'), 'wb') as f:
|
|
|
|
|
pickle.dump(im_epsg, f)
|
|
|
|
|
|
|
|
|
|
#with open(os.path.join(filepath, sitename + '_timestamps' + '.pkl'), 'wb') as f:
|
|
|
|
|
# pickle.dump(timestamps, f)
|
|
|
|
|
#with open(os.path.join(filepath, sitename + '_epsgcode' + '.pkl'), 'wb') as f:
|
|
|
|
|
# pickle.dump(im_epsg, f)
|
|
|
|
|
with open(os.path.join(filepath, sitename + '_accuracy_georef' + '.pkl'), 'wb') as f:
|
|
|
|
|
pickle.dump(acc_georef, f)
|