|
|
|
@ -40,6 +40,8 @@ plot_bool = False # if you want the plots
|
|
|
|
|
prob_high = 99.9 # upper probability to clip and rescale pixel intensity
|
|
|
|
|
min_contour_points = 100# minimum number of points contained in each water line
|
|
|
|
|
output_epsg = 28356 # GDA94 / MGA Zone 56
|
|
|
|
|
buffer_size = 10 # radius (in pixels) of disk for buffer (pixel classification)
|
|
|
|
|
min_beach_size = 50 # number of pixels in a beach (pixel classification)
|
|
|
|
|
|
|
|
|
|
# load metadata (timestamps and epsg code) for the collection
|
|
|
|
|
satname = 'L8'
|
|
|
|
@ -127,7 +129,7 @@ for i in range(N):
|
|
|
|
|
idx_skipped.append(i)
|
|
|
|
|
continue
|
|
|
|
|
else:
|
|
|
|
|
del shorelines[idx_samedate]
|
|
|
|
|
# del shorelines[idx_samedate]
|
|
|
|
|
del t[idx_samedate]
|
|
|
|
|
del cloud_cover_ts[idx_samedate]
|
|
|
|
|
del date_acquired_ts[idx_samedate]
|
|
|
|
@ -150,39 +152,43 @@ for i in range(N):
|
|
|
|
|
# convert to output epsg spatial reference
|
|
|
|
|
wl = sds.convert_epsg(wl_coords, input_epsg, output_epsg)
|
|
|
|
|
|
|
|
|
|
# plot a figure to select the correct water line and discard cloudy images
|
|
|
|
|
plt.figure()
|
|
|
|
|
cmap = cm.get_cmap('jet')
|
|
|
|
|
plt.subplot(121)
|
|
|
|
|
plt.imshow(im_ms_ps[:,:,[2,1,0]])
|
|
|
|
|
for j,contour in enumerate(wl_pix):
|
|
|
|
|
colours = cmap(np.linspace(0, 1, num=len(wl_pix)))
|
|
|
|
|
plt.plot(contour[:, 1], contour[:, 0], linewidth=2, color=colours[j,:])
|
|
|
|
|
plt.axis('image')
|
|
|
|
|
plt.title(file_names_pan[i])
|
|
|
|
|
plt.subplot(122)
|
|
|
|
|
centroids = []
|
|
|
|
|
for j,contour in enumerate(wl):
|
|
|
|
|
colours = cmap(np.linspace(0, 1, num=len(wl)))
|
|
|
|
|
centroids.append([np.mean(contour[:, 0]),np.mean(contour[:, 1])])
|
|
|
|
|
plt.plot(contour[:, 0], contour[:, 1], linewidth=2, color=colours[j,:])
|
|
|
|
|
plt.plot(np.mean(contour[:, 0]), np.mean(contour[:, 1]), 'o', color=colours[j,:])
|
|
|
|
|
plt.plot(refpoints[:,0], refpoints[:,1], 'k.')
|
|
|
|
|
plt.axis('equal')
|
|
|
|
|
plt.title(file_names_pan[i])
|
|
|
|
|
mng = plt.get_current_fig_manager()
|
|
|
|
|
mng.window.showMaximized()
|
|
|
|
|
plt.tight_layout()
|
|
|
|
|
plt.draw()
|
|
|
|
|
# click on the left image to discard, otherwise on the closest centroid in the right image
|
|
|
|
|
pt_in = np.array(ginput(n=1, timeout=1000))
|
|
|
|
|
if pt_in[0][0] < 10000:
|
|
|
|
|
print('skip ' + str(i) + ' - manual')
|
|
|
|
|
idx_skipped.append(i)
|
|
|
|
|
continue
|
|
|
|
|
# get contour that was selected (clock closest to centroid)
|
|
|
|
|
dist_centroid = [np.linalg.norm(_ - pt_in) for _ in centroids]
|
|
|
|
|
shorelines.append(wl[np.argmin(dist_centroid)])
|
|
|
|
|
# classify sand pixels
|
|
|
|
|
im_sand = sds.classify_sand_unsupervised(im_ms_ps, im_pan, cloud_mask, wl_pix, False, min_beach_size, True)
|
|
|
|
|
|
|
|
|
|
# # plot a figure to select the correct water line and discard cloudy images
|
|
|
|
|
# plt.figure()
|
|
|
|
|
# cmap = cm.get_cmap('jet')
|
|
|
|
|
# plt.subplot(121)
|
|
|
|
|
# plt.imshow(im_ms_ps[:,:,[2,1,0]])
|
|
|
|
|
# for j,contour in enumerate(wl_pix):
|
|
|
|
|
# colours = cmap(np.linspace(0, 1, num=len(wl_pix)))
|
|
|
|
|
# plt.plot(contour[:, 1], contour[:, 0], linewidth=2, color=colours[j,:])
|
|
|
|
|
# plt.axis('image')
|
|
|
|
|
# plt.title(file_names_pan[i])
|
|
|
|
|
# plt.subplot(122)
|
|
|
|
|
# centroids = []
|
|
|
|
|
# for j,contour in enumerate(wl):
|
|
|
|
|
# colours = cmap(np.linspace(0, 1, num=len(wl)))
|
|
|
|
|
# centroids.append([np.mean(contour[:, 0]),np.mean(contour[:, 1])])
|
|
|
|
|
# plt.plot(contour[:, 0], contour[:, 1], linewidth=2, color=colours[j,:])
|
|
|
|
|
# plt.plot(np.mean(contour[:, 0]), np.mean(contour[:, 1]), 'o', color=colours[j,:])
|
|
|
|
|
# plt.plot(refpoints[:,0], refpoints[:,1], 'k.')
|
|
|
|
|
# plt.axis('equal')
|
|
|
|
|
# plt.title(file_names_pan[i])
|
|
|
|
|
# mng = plt.get_current_fig_manager()
|
|
|
|
|
# mng.window.showMaximized()
|
|
|
|
|
# plt.tight_layout()
|
|
|
|
|
# plt.draw()
|
|
|
|
|
# # click on the left image to discard, otherwise on the closest centroid in the right image
|
|
|
|
|
# pt_in = np.array(ginput(n=1, timeout=1000))
|
|
|
|
|
# if pt_in[0][0] < 10000:
|
|
|
|
|
# print('skip ' + str(i) + ' - manual')
|
|
|
|
|
# idx_skipped.append(i)
|
|
|
|
|
# continue
|
|
|
|
|
# # get contour that was selected (click closest to centroid)
|
|
|
|
|
# dist_centroid = [np.linalg.norm(_ - pt_in) for _ in centroids]
|
|
|
|
|
# shorelines.append(wl[np.argmin(dist_centroid)])
|
|
|
|
|
|
|
|
|
|
t.append(timestamps_sorted[i])
|
|
|
|
|
cloud_cover_ts.append(cloud_cover)
|
|
|
|
|
acc_georef_ts.append(acc_georef_sorted[i])
|
|
|
|
|