|
|
```markdown
|
|
|
# Code Overview
|
|
|
|
|
|
This code provides various functions for processing and analyzing geographical and satellite data using the Earth Engine and Turf.js libraries. It includes functions for land cover parsing, shoreline extraction, cloud masking, and vegetation index calculations.
|
|
|
|
|
|
## Dependencies
|
|
|
|
|
|
- `earth-engine` (imported as `ee`)
|
|
|
- `@turf/turf` (imported as `turf`)
|
|
|
- `../../common/satellites` (imported as `satellite`)
|
|
|
|
|
|
## Functions
|
|
|
|
|
|
### `landParsing`
|
|
|
|
|
|
Parses land cover data to determine intersections and distances.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `landcover` (Object): The land cover data.
|
|
|
- `sidesCoords` (Array): Coordinates of the sides.
|
|
|
- `centerCoord` (Array): Center coordinates.
|
|
|
- `shoreline` (Object): Shoreline geometry.
|
|
|
|
|
|
**Returns:**
|
|
|
- Object containing parsed land cover data.
|
|
|
|
|
|
### `landParsingTurf`
|
|
|
|
|
|
Similar to `landParsing` but uses Turf.js for geometric operations.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `landcover` (Object): The land cover data.
|
|
|
- `sidesCoords` (Array): Coordinates of the sides.
|
|
|
- `centerCoord` (Array): Center coordinates.
|
|
|
- `shoreline` (Object): Shoreline geometry.
|
|
|
|
|
|
**Returns:**
|
|
|
- Object containing parsed land cover data.
|
|
|
|
|
|
### `extractShoreLine`
|
|
|
|
|
|
Extracts the shoreline from baseline coordinates and water geometry.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `baseLineCoords` (Array): Baseline coordinates.
|
|
|
- `waterGeometry` (Object): Water geometry.
|
|
|
|
|
|
**Returns:**
|
|
|
- Shoreline geometry.
|
|
|
|
|
|
### `extractShoreLineTurf`
|
|
|
|
|
|
Similar to `extractShoreLine` but uses Turf.js for geometric operations.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `baseLine` (Object): Baseline geometry.
|
|
|
- `waterGeometry` (Object): Water geometry.
|
|
|
|
|
|
**Returns:**
|
|
|
- Shoreline geometry.
|
|
|
|
|
|
### `landCoversIntersections`
|
|
|
|
|
|
Calculates intersections of land covers along a transect.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `transect` (Object): Transect data.
|
|
|
- `landcoversdata` (Array): Land cover data.
|
|
|
- `shoreLine` (Object): Shoreline geometry.
|
|
|
- `year` (Number): Year of the data.
|
|
|
|
|
|
**Returns:**
|
|
|
- Object containing land cover intersections.
|
|
|
|
|
|
### `landCoversIntersectionsTurf`
|
|
|
|
|
|
Similar to `landCoversIntersections` but uses Turf.js for geometric operations.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `transect` (Object): Transect data.
|
|
|
- `landcoversdata` (Array): Land cover data.
|
|
|
- `shoreLine` (Object): Shoreline geometry.
|
|
|
- `year` (Number): Year of the data.
|
|
|
|
|
|
**Returns:**
|
|
|
- Object containing land cover intersections.
|
|
|
|
|
|
### `filterElevation`
|
|
|
|
|
|
Filters an image based on elevation.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `image` (Object): The image to filter.
|
|
|
- `elevation` (Number): Elevation threshold.
|
|
|
- `type` (String, optional): Type of filtering.
|
|
|
- `satellite` (String, optional): Satellite name.
|
|
|
|
|
|
**Returns:**
|
|
|
- Filtered image.
|
|
|
|
|
|
### `applyScaleFactors`
|
|
|
|
|
|
Applies scale factors to an image.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `image` (Object): The image to scale.
|
|
|
|
|
|
**Returns:**
|
|
|
- Scaled image.
|
|
|
|
|
|
### `getMapBiomasClassificationsList`
|
|
|
|
|
|
Retrieves a list of MapBiomas classifications.
|
|
|
|
|
|
**Returns:**
|
|
|
- Array of classification IDs.
|
|
|
|
|
|
### `getMapBiomasClassificationYear`
|
|
|
|
|
|
Retrieves MapBiomas classification for a specific year.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `AOI` (Array): Area of interest.
|
|
|
- `year` (Number): Year of the classification.
|
|
|
- `elevation` (Number, optional): Elevation threshold.
|
|
|
|
|
|
**Returns:**
|
|
|
- Classified image.
|
|
|
|
|
|
### `getLandCoverLabelMapBiomas`
|
|
|
|
|
|
Maps a value to a land cover label based on MapBiomas classifications.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `value` (Number): The value to map.
|
|
|
|
|
|
**Returns:**
|
|
|
- Land cover label.
|
|
|
|
|
|
### `maskCloudLandsat`
|
|
|
|
|
|
Masks clouds in a Landsat image.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `image` (Object): The image to mask.
|
|
|
- `qa_band` (String): Quality assurance band.
|
|
|
|
|
|
**Returns:**
|
|
|
- Cloud-masked image.
|
|
|
|
|
|
### `maskCloudSentinel`
|
|
|
|
|
|
Masks clouds in a Sentinel image.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `image` (Object): The image to mask.
|
|
|
|
|
|
**Returns:**
|
|
|
- Cloud-masked image.
|
|
|
|
|
|
### `getImageCSqueezeInfos`
|
|
|
|
|
|
Retrieves metadata for a given mission name.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `missionName` (String): The mission name.
|
|
|
|
|
|
**Returns:**
|
|
|
- Object containing metadata.
|
|
|
|
|
|
### `applySaviBand`
|
|
|
|
|
|
Applies the SAVI band to an image.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `image` (Object): The image to process.
|
|
|
- `bands` (Object): Band names.
|
|
|
|
|
|
**Returns:**
|
|
|
- Image with SAVI band.
|
|
|
|
|
|
### `applyEviBand`
|
|
|
|
|
|
Applies the EVI band to an image.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `image` (Object): The image to process.
|
|
|
- `bands` (Object): Band names.
|
|
|
|
|
|
**Returns:**
|
|
|
- Image with EVI band.
|
|
|
|
|
|
### `applyNdviBand`
|
|
|
|
|
|
Applies the NDVI band to an image.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `image` (Object): The image to process.
|
|
|
- `bands` (Object): Band names.
|
|
|
|
|
|
**Returns:**
|
|
|
- Image with NDVI band.
|
|
|
|
|
|
### `applyMndwiBand`
|
|
|
|
|
|
Applies the MNDWI band to an image.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `image` (Object): The image to process.
|
|
|
- `bands` (Object): Band names.
|
|
|
|
|
|
**Returns:**
|
|
|
- Image with MNDWI band.
|
|
|
|
|
|
### `applyUiBand`
|
|
|
|
|
|
Applies the UI band to an image.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `image` (Object): The image to process.
|
|
|
- `bands` (Object): Band names.
|
|
|
|
|
|
**Returns:**
|
|
|
- Image with UI band.
|
|
|
|
|
|
### `trainAndClassify`
|
|
|
|
|
|
Trains a classifier and classifies an image.
|
|
|
|
|
|
**Parameters:**
|
|
|
- `image` (Object): The image to classify.
|
|
|
- `classificationAreas` (Object): Training data.
|
|
|
- `bands` (Array): Band names.
|
|
|
- `AOICoords` (Array): Area of interest coordinates.
|
|
|
|
|
|
**Returns:**
|
|
|
- Classified image.
|
|
|
|
|
|
### `getMangroves`
|
|
|
|
|
|
Retrieves mangrove data from the ESA WorldCover dataset.
|
|
|
|
|
|
**Returns:**
|
|
|
- Mangrove overlay.
|
|
|
```
|
|
|
|
|
|
|