Code Overview
This code is designed to generate transects orthogonal to a specified polygon and expand them horizontally. It utilizes the Google Earth Engine (GEE) library and some geodesic computations to achieve this.
Dependencies
- Google Earth Engine (
ee
) - Geodesy utilities (
computeBearing
,computeDisplacement
) - Metadata constants (
INTERNALS
)
Functions
offsetMapper(extent, origin, theta)
Creates a function that maps offsets to transects.
Parameters
-
extent
(Number): The extent of the transect. -
origin
(List): The origin point for the transect. -
theta
(Number): The angle for the transect.
Returns
- Function: A function that takes an offset and returns a transect as an
ee.Feature
.
transectAccumulator(step, extent)
Creates a function that accumulates transects along a path.
Parameters
-
step
(Number): The step size for the transects. -
extent
(Number): The extent of the transect.
Returns
- Function: A function that takes the current and last points and returns an accumulated list of transects.
generateOrthogonalTransects(coordinates, step, extent)
Generates transects orthogonal to the specified polygon.
Parameters
-
coordinates
(ee.List): A list of coordinates defining the polygon. -
step
(Number): The step size for the transects. -
extent
(Number): The extent of the transect.
Returns
-
ee.List
: A list of transects asee.FeatureCollection
.
Example Usage
const coordinates = ee.List([
[0, 0],
[1, 1],
[2, 2],
]);
const step = 10;
const extent = 5;
const transects = generateOrthogonalTransects(coordinates, step, extent);
expandHorizontally(transects, amount)
Expands the transects horizontally by a specified amount.
Parameters
-
transects
(ee.List): A list of transects asee.FeatureCollection
. -
amount
(Number): The amount to expand the transects.
Returns
-
ee.List
: A list of expanded transects asee.FeatureCollection
.
Example Usage
const expandedTransects = expandHorizontally(transects, 10);
Edge Cases and Assumptions
- Assumes that the input coordinates are in a valid format and order.
- Assumes that the step and extent values are positive numbers.
- Handles cases where the space between transects is greater than the length of the segment.
References
- Google Earth Engine: https://developers.google.com/earth-engine/
- Geodesy computations: Internal utility functions
computeBearing
andcomputeDisplacement
.