Esempio n. 1
0
def main(polygon, dates, sat_list, sitename, vidType, rate):
    # filepath where data will be stored
    filepath_data = os.path.join(os.getcwd(), 'data')

    # put all the inputs into a dictionnary
    inputs = {
        'polygon': polygon,
        'dates': dates,
        'sat_list': sat_list,
        'sitename': sitename,
        'filepath': filepath_data,
    }

    #%% 2. Retrieve images

    ### retrieve satellite images from GEE
    metadata = SDS_download.retrieve_images(inputs)
    ##
    ### if you have already downloaded the images, just load the metadata file
    metadata = SDS_download.get_metadata(inputs)
    ##
    ###%% 3. Batch island contour detection
    ##
    ### settings for the sand contour mapping
    settings = {
        # general parameters:
        'cloud_thresh': 0.5,  # threshold on maximum cloud cover
        'output_epsg':
        3857,  # epsg code of spatial reference system desired for the output
        # quality control:
        'check_detection_sand_poly':
        True,  # if True, uses sand polygon for detection and shows user for validation 
        'save_figure':
        True,  # if True, saves a figure showing the mapped shoreline for each image
        # add the inputs defined previously
        'inputs': inputs,
        # [ONLY FOR ADVANCED USERS] shoreline detection parameters:
        'min_beach_area':
        50,  # minimum area (in metres^2) for an object to be labelled as a beach
        'buffer_size':
        100,  # radius (in metres) of the buffer around sandy pixels considered in the shoreline detection
        'min_length_sl':
        500,  # minimum length (in metres) of shoreline perimeter to be valid
        'cloud_mask_issue':
        False,  # switch this parameter to True if sand pixels are masked (in black) on many images
        'sand_color':
        'default',  # 'default', 'dark' (for grey/black sand beaches) or 'bright' (for white sand beaches)
    }
    ##
    ### [OPTIONAL] preprocess images (cloud masking, pansharpening/down-sampling)
    SDS_preprocess.save_jpg(metadata, settings, vidType)
    videoName = os.path.join(filepath_data, sitename, sitename + '.avi')
    imageFolder = os.path.join(filepath_data, sitename, 'jpg_files',
                               'preprocessed')
    makeVideo(imageFolder, videoName, rate)
Esempio n. 2
0
    'inputs': inputs,
    # [ONLY FOR ADVANCED USERS] shoreline detection parameters:
    'min_beach_area':
    4500,  # minimum area (in metres^2) for an object to be labelled as a beach
    'buffer_size':
    150,  # radius (in metres) of the buffer around sandy pixels considered in the shoreline detection
    'min_length_sl':
    200,  # minimum length (in metres) of shoreline perimeter to be valid
    'cloud_mask_issue':
    False,  # switch this parameter to True if sand pixels are masked (in black) on many images  
    'sand_color':
    'default',  # 'default', 'dark' (for grey/black sand beaches) or 'bright' (for white sand beaches)
}

# [OPTIONAL] preprocess images (cloud masking, pansharpening/down-sampling)
SDS_preprocess.save_jpg(metadata, settings)

# [OPTIONAL] create a reference shoreline (helps to identify outliers and false detections)
settings['reference_shoreline'] = SDS_preprocess.get_reference_sl(
    metadata, settings)
# set the max distance (in meters) allowed from the reference shoreline for a detected shoreline to be valid
settings['max_dist_ref'] = 100

# extract shorelines from all images (also saves output.pkl and shorelines.kml)
output = SDS_shoreline.extract_shorelines(metadata, settings)

# plot the mapped shorelines
fig = plt.figure()
plt.axis('equal')
plt.xlabel('Eastings')
plt.ylabel('Northings')