Shoreline Extraction Algorithms
This code file contains a set of functions designed to process satellite imagery and extract shoreline features. The primary purpose is to identify water bodies, remove noise from shorelines, and apply various filters to produce clean and accurate shoreline data.
Dependencies
-
earth-engine
(ee) -
geodesy
for geospatial calculations -
metadata
for handling metadata -
utils
for utility functions -
tools/effects
for callback and evaluation functions -
@material-ui/icons
for UI icons
Functions
identifyWaterFeature
Partitions the raster image using the water index and the threshold function, then reduces the output raster to vector, corresponding to the water body in the given image.
Parameters:
-
image
(ee.Image): The input image. -
geometry
(ee.Geometry): The area of interest. -
scale
(Number): The scale of the analysis. -
bands
(Object): The bands to be used for the water index. -
thresholdFn
(Function): The function to determine the threshold.
Returns:
-
ee.Geometry
: The identified water body.
removeShorelineNoise
Removes noises from the shoreline by keeping only the polygons that have the most intersections with the transects.
Parameters:
-
shorelines
(ee.Geometry.MultiLineString): The input shorelines. -
transects
(ee.Geometry.MultiLineString | ee.FeatureCollection): The transects for noise removal.
Returns:
-
ee.Feature<ee.Geometry.LineString>
: The shoreline without noise.
gaussianKernel
Creates a Gaussian kernel controlled by size, mean, and sigma. The output kernel size is always odd.
Parameters:
-
size
(Number): The size of the kernel. -
mean
(Number): The mean of the Gaussian distribution. -
sigma
(Number): The standard deviation of the Gaussian distribution.
Returns:
-
ee.List<Number>
: The Gaussian kernel.
linearGaussianFilter
Convolves over the list of coordinates producing local averages weighted by the produced kernel of samples, mean, and sd. The result is a smoothed list with removed noises.
Parameters:
-
coordinates
(ee.List): List containing the path. -
samples
(ee.Number): Size of the kernel (default: 3). -
mean
(ee.Number): Center of the normal distribution (default: 0). -
sd
(ee.Number): Standard Deviation (default: 1).
Returns:
-
ee.List<Number>
: The filtered coordinates.
thresholdingAlgorithm
Given a histogram, finds the appropriate thresholds for a specified number of classes.
Parameters:
-
histogram
(ee.Dictionary): The input histogram. -
count
(Number): The number of classes.
Returns:
-
ee.Number
: The optimal threshold.
selectThreshold
Selects the threshold function according to the input threshold.
Parameters:
-
threshold
(Number): The input threshold.
Returns:
-
Function
: The thresholding function.
extractShoreline
Extracts the raw shoreline of the given image by identifying the water feature and converting it into linestrings.
Parameters:
-
image
(ee.Image): The input image. -
geometry
(ee.Geometry): The area of interest. -
scale
(Number): The scale of the analysis. -
bands
(Object): The bands to be used. -
thresholdFn
(Function): The function to determine the threshold.
Returns:
-
ee.Geometry.MultiLineString
: The extracted shoreline.
deriveShoreline
Fully derives the shoreline using the satellite image. The satellite-derived shoreline is a single smoothed linestring without noisy features.
Parameters:
-
image
(ee.Image): The input image. -
geometry
(ee.Geometry): The area of interest. -
scale
(Number): The scale of the analysis. -
bands
(Object): The bands to be used. -
threshold
(Function): The threshold function. -
transects
(ee.FeatureCollection | ee.List): The transects for noise removal. -
props
(Array): Additional properties. -
opticalResolution
(Number): The optical resolution of the satellite.
Returns:
-
ee.Feature
: The derived shoreline.
deriveShorelines
Acquires and extracts shorelines given an array of dates.
Parameters:
-
dates
(Array): A list containing the dates of the images to be analyzed. -
satellite
(Object): Information about the satellite. -
geometry
(ee.Geometry): The area of interest. -
scale
(Number): The scale of the analysis. -
threshold
(ee.Number): Suggested threshold for the extraction. -
transects
(ee.FeatureCollection | ee.List): The transects for noise removal.
Returns:
-
ee.FeatureCollection
: A FeatureCollection of polygons.
expandCoastline
Expands the given coordinates by a specified distance.
Parameters:
-
coordinates
(ee.List): The input coordinates. -
distance
(Number): The distance to expand.
Returns:
-
ee.Feature
: The expanded coastline.
rectifyJunctions
Normalizes the junctions of segments.
Parameters:
-
segments
(ee.List): The input segments. -
originalCoordinates
(ee.List): The original coordinates.
Returns:
-
ee.List
: The rectified junctions.