... | @@ -11,18 +11,15 @@ |
... | @@ -11,18 +11,15 @@ |
|
|
|
|
|
# Activity Documentation for Csqueeze Module
|
|
# Activity Documentation for Csqueeze Module
|
|
|
|
|
|
This documentation provides a detailed explanation of the user
|
|
This documentation provides a detailed explanation of the user interaction pages in the Csqueeze module.
|
|
interaction pages in the Csqueeze module.
|
|
|
|
|
|
|
|
## Diagram
|
|
## Diagram
|
|
|
|
|
|
[1100x1100px](Arquivo:Csqueeze_Activity_Diagram.png "wikilink")
|
|

|
|
|
|
|
|
## app/pages/SelectionPage
|
|
## app/pages/SelectionPage
|
|
|
|
|
|
This page shows the options available to the user. When the user chooses
|
|
This page shows the options available to the user. When the user chooses the Coastal Squeeze option, the page redirects to the app/pages/CSqueeze page.
|
|
the Coastal Squeeze option, the page redirects to the app/pages/CSqueeze
|
|
|
|
page.
|
|
|
|
|
|
|
|
## app/pages/CSqueeze
|
|
## app/pages/CSqueeze
|
|
|
|
|
... | @@ -34,71 +31,51 @@ This page shows the processing screen for the Coastal Squeeze analysis. |
... | @@ -34,71 +31,51 @@ This page shows the processing screen for the Coastal Squeeze analysis. |
|
|
|
|
|
## app/components/csqueeze/AOIChooser
|
|
## app/components/csqueeze/AOIChooser
|
|
|
|
|
|
This component is responsible for the user to choose the Area of
|
|
This component is responsible for the user to choose the Area of Interest (AOI). It has the following functions:
|
|
Interest (AOI). It has the following functions:
|
|
|
|
|
|
|
|
### getMangroves()
|
|
### getMangroves()
|
|
|
|
|
|
This function, from algorithms/csqueeze, uses the "ESA/WorldCover/v200"
|
|
This function, from algorithms/csqueeze, uses the "ESA/WorldCover/v200" collection to get possible mangrove areas around the world.
|
|
collection to get possible mangrove areas around the world.
|
|
|
|
|
|
|
|
### useEffect()
|
|
### useEffect()
|
|
|
|
|
|
This useEffect calls getMangroves() when the component is mounted to
|
|
This useEffect calls getMangroves() when the component is mounted to show possible mangrove areas on the map.
|
|
show possible mangrove areas on the map.
|
|
|
|
|
|
|
|
### handleMapClick()
|
|
### handleMapClick()
|
|
|
|
|
|
This function is called when the user clicks on the map. It starts the
|
|
This function is called when the user clicks on the map. It starts the drawing of the AOI using the Google Maps Drawing Manager.
|
|
drawing of the AOI using the Google Maps Drawing Manager.
|
|
|
|
|
|
|
|
### endDrawing()
|
|
### endDrawing()
|
|
|
|
|
|
This function is called when the drawing of the AOI is finished. It gets
|
|
This function is called when the drawing of the AOI is finished. It gets the AOI coordinates, area, and overlay and saves them in the state and in the Redux store using dispatch(Acquisition.setAreaOfInterest()).
|
|
the AOI coordinates, area, and overlay and saves them in the state and
|
|
|
|
in the Redux store using dispatch(Acquisition.setAreaOfInterest()).
|
|
|
|
|
|
|
|
## app/components/csqueeze/YearsSelect
|
|
## app/components/csqueeze/YearsSelect
|
|
|
|
|
|
This component shows a slider for the user to select two years to
|
|
This component shows a slider for the user to select two years to perform the analysis. When the years are selected, they are saved in the Redux store using dispatch(Acquisition.setDates()).
|
|
perform the analysis. When the years are selected, they are saved in the
|
|
|
|
Redux store using dispatch(Acquisition.setDates()).
|
|
|
|
|
|
|
|
## app/components/csqueeze/ImagesSelect
|
|
## app/components/csqueeze/ImagesSelect
|
|
|
|
|
|
This component shows the available images for the selected years and
|
|
This component shows the available images for the selected years and AOI. The user must choose at least one image for each year. When the images are selected, they are saved in the Redux store using dispatch(Acquisition.setImages()).
|
|
AOI. The user must choose at least one image for each year. When the
|
|
|
|
images are selected, they are saved in the Redux store using
|
|
|
|
dispatch(Acquisition.setImages()).
|
|
|
|
|
|
|
|
## app/components/csqueeze/CloudFilters
|
|
## app/components/csqueeze/CloudFilters
|
|
|
|
|
|
This component shows the available cloud filters for the selected
|
|
This component shows the available cloud filters for the selected images. The user must choose at least one filter. When the filters are selected, they are saved in the Redux store using dispatch(Acquisition.setCloudFilters()).
|
|
images. The user must choose at least one filter. When the filters are
|
|
|
|
selected, they are saved in the Redux store using
|
|
|
|
dispatch(Acquisition.setCloudFilters()).
|
|
|
|
|
|
|
|
## app/components/csqueeze/LandCover
|
|
## app/components/csqueeze/LandCover
|
|
|
|
|
|
This component shows the map with the selected images and AOI. The user
|
|
This component shows the map with the selected images and AOI. The user must draw at least one polygon of mangrove and another type of land cover. When the polygons are drawn, they are saved in the Redux store using dispatch(Acquisition.setLandCover()).
|
|
must draw at least one polygon of mangrove and another type of land
|
|
|
|
cover. When the polygons are drawn, they are saved in the Redux store
|
|
|
|
using dispatch(Acquisition.setLandCover()).
|
|
|
|
|
|
|
|
## algorithms/acquisition
|
|
## algorithms/acquisition
|
|
|
|
|
|
This module contains the functions to acquire the satellite images and
|
|
This module contains the functions to acquire the satellite images and perform the cloud masking.
|
|
perform the cloud masking.
|
|
|
|
|
|
|
|
### getSatelliteImages()
|
|
### getSatelliteImages()
|
|
|
|
|
|
This function gets the satellite images for the selected years and AOI
|
|
This function gets the satellite images for the selected years and AOI using the Google Earth Engine API.
|
|
using the Google Earth Engine API.
|
|
|
|
|
|
|
|
### maskClouds()
|
|
### maskClouds()
|
|
|
|
|
|
This function masks the clouds in the selected images using the cloud
|
|
This function masks the clouds in the selected images using the cloud filters selected by the user.
|
|
filters selected by the user.
|
|
|
|
|
|
|
|
## algorithms/geodesy
|
|
## algorithms/geodesy
|
|
|
|
|
... | @@ -106,77 +83,61 @@ This module contains the functions to perform the geodesic calculations. |
... | @@ -106,77 +83,61 @@ This module contains the functions to perform the geodesic calculations. |
|
|
|
|
|
### calculateArea()
|
|
### calculateArea()
|
|
|
|
|
|
This function calculates the area of the AOI in square kilometers using
|
|
This function calculates the area of the AOI in square kilometers using the Haversine formula.
|
|
the Haversine formula.
|
|
|
|
|
|
|
|
### calculateDistance()
|
|
### calculateDistance()
|
|
|
|
|
|
This function calculates the distance between two points in meters using
|
|
This function calculates the distance between two points in meters using the Vincenty formula.
|
|
the Vincenty formula.
|
|
|
|
|
|
|
|
## algorithms/satellite
|
|
## algorithms/satellite
|
|
|
|
|
|
This module contains the functions to perform the Coastal Squeeze
|
|
This module contains the functions to perform the Coastal Squeeze analysis.
|
|
analysis.
|
|
|
|
|
|
|
|
### calculateNDVI()
|
|
### calculateNDVI()
|
|
|
|
|
|
This function calculates the Normalized Difference Vegetation Index
|
|
This function calculates the Normalized Difference Vegetation Index (NDVI) for the selected images.
|
|
(NDVI) for the selected images.
|
|
|
|
|
|
|
|
### calculateShoreline()
|
|
### calculateShoreline()
|
|
|
|
|
|
This function calculates the shoreline for the selected images using the
|
|
This function calculates the shoreline for the selected images using the mangrove and land cover polygons drawn by the user.
|
|
mangrove and land cover polygons drawn by the user.
|
|
|
|
|
|
|
|
## algorithms/utils
|
|
## algorithms/utils
|
|
|
|
|
|
This module contains utility functions used in the Coastal Squeeze
|
|
This module contains utility functions used in the Coastal Squeeze analysis.
|
|
analysis.
|
|
|
|
|
|
|
|
### getPolygonArea()
|
|
### getPolygonArea()
|
|
|
|
|
|
This function calculates the area of a polygon in square kilometers
|
|
This function calculates the area of a polygon in square kilometers using the Shoelace formula.
|
|
using the Shoelace formula.
|
|
|
|
|
|
|
|
### getPolygonPerimeter()
|
|
### getPolygonPerimeter()
|
|
|
|
|
|
This function calculates the perimeter of a polygon in meters using the
|
|
This function calculates the perimeter of a polygon in meters using the Haversine formula.
|
|
Haversine formula.
|
|
|
|
|
|
|
|
## app/pages/ProcessingPage
|
|
## app/pages/ProcessingPage
|
|
|
|
|
|
This page shows the final maps and analysis for the Coastal Squeeze. It
|
|
This page shows the final maps and analysis for the Coastal Squeeze. It uses the data saved in the Redux store from the previous steps.
|
|
uses the data saved in the Redux store from the previous steps.
|
|
|
|
|
|
|
|
### useEffect()
|
|
### useEffect()
|
|
|
|
|
|
This useEffect calls the following functions when the component is
|
|
This useEffect calls the following functions when the component is mounted:
|
|
mounted:
|
|
|
|
|
|
|
|
\- getSatelliteImages() - maskClouds() - calculateNDVI() -
|
|
\- getSatelliteImages() - maskClouds() - calculateNDVI() - calculateShoreline()
|
|
calculateShoreline()
|
|
|
|
|
|
|
|
### calculateCoastalSqueeze()
|
|
### calculateCoastalSqueeze()
|
|
|
|
|
|
This function calculates the Coastal Squeeze index for the selected
|
|
This function calculates the Coastal Squeeze index for the selected images and displays the results on the map. It uses the following functions:
|
|
images and displays the results on the map. It uses the following
|
|
|
|
functions:
|
|
|
|
|
|
|
|
\- calculateArea() - calculateDistance() - getPolygonArea() -
|
|
\- calculateArea() - calculateDistance() - getPolygonArea() - getPolygonPerimeter()
|
|
getPolygonPerimeter()
|
|
|
|
|
|
|
|
The results are saved in the Redux store using
|
|
The results are saved in the Redux store using dispatch(Acquisition.setCoastalSqueeze()).
|
|
dispatch(Acquisition.setCoastalSqueeze()).
|
|
|
|
|
|
|
|
## Code Used in Csqueeze
|
|
## Code Used in Csqueeze
|
|
|
|
|
|
### **getMangroves()**
|
|
### **getMangroves()**
|
|
|
|
|
|
This function returns a Google Maps layer with possible mangrove areas
|
|
This function returns a Google Maps layer with possible mangrove areas around the world using the "ESA/WorldCover/v200" collection.
|
|
around the world using the "ESA/WorldCover/v200" collection.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
function getMangroves() {
|
|
function getMangroves() {
|
|
var mangroves = ee.ImageCollection("ESA/WorldCover/v200")
|
|
var mangroves = ee.ImageCollection("ESA/WorldCover/v200")
|
... | @@ -203,10 +164,9 @@ Google Maps layer with possible mangrove areas. |
... | @@ -203,10 +164,9 @@ Google Maps layer with possible mangrove areas. |
|
|
|
|
|
#### **Use**
|
|
#### **Use**
|
|
|
|
|
|
To use this function, simply call getMangroves() and add the returned
|
|
To use this function, simply call getMangroves() and add the returned Google Maps layer to the map using map.addLayer().
|
|
Google Maps layer to the map using map.addLayer().
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
var mangrovesLayer = getMangroves();
|
|
var mangrovesLayer = getMangroves();
|
|
map.addLayer(mangrovesLayer);
|
|
map.addLayer(mangrovesLayer);
|
... | @@ -214,11 +174,9 @@ map.addLayer(mangrovesLayer); |
... | @@ -214,11 +174,9 @@ map.addLayer(mangrovesLayer); |
|
|
|
|
|
### **useEffect()**
|
|
### **useEffect()**
|
|
|
|
|
|
This React hook runs when the component mounts and unmounts. It adds a
|
|
This React hook runs when the component mounts and unmounts. It adds a Google Maps layer showing possible mangrove areas and a drawing manager to the map.
|
|
Google Maps layer showing possible mangrove areas and a drawing manager
|
|
|
|
to the map.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
mangroveLayer.current = getMangroves();
|
|
mangroveLayer.current = getMangroves();
|
... | @@ -250,20 +208,17 @@ No input parameters. This is a React hook. |
... | @@ -250,20 +208,17 @@ No input parameters. This is a React hook. |
|
|
|
|
|
#### **Output:**
|
|
#### **Output:**
|
|
|
|
|
|
A Google Maps layer showing possible mangrove areas and a drawing
|
|
A Google Maps layer showing possible mangrove areas and a drawing manager are added to the map.
|
|
manager are added to the map.
|
|
|
|
|
|
|
|
#### **Use**
|
|
#### **Use**
|
|
|
|
|
|
Since this is a React hook, it will run automatically when the component
|
|
Since this is a React hook, it will run automatically when the component mounts. No usage example is needed.
|
|
mounts. No usage example is needed.
|
|
|
|
|
|
|
|
### **handleMapClick()**
|
|
### **handleMapClick()**
|
|
|
|
|
|
This function handles clicks on the map. It checks if the click was
|
|
This function handles clicks on the map. It checks if the click was within the AOI and either starts or ends the drawing of a rectangle.
|
|
within the AOI and either starts or ends the drawing of a rectangle.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
function handleMapClick(event) {
|
|
function handleMapClick(event) {
|
|
if (isPointInside(event.latLng, AOI.current.getPath())) {
|
|
if (isPointInside(event.latLng, AOI.current.getPath())) {
|
... | @@ -288,12 +243,9 @@ Either starts or ends the drawing of a rectangle on the map. |
... | @@ -288,12 +243,9 @@ Either starts or ends the drawing of a rectangle on the map. |
|
|
|
|
|
#### **Use**
|
|
#### **Use**
|
|
|
|
|
|
This function is set as the click listener on the map. Whenever the map
|
|
This function is set as the click listener on the map. Whenever the map is clicked, this function will handle the click and check if the click was within the AOI, in which case it will either start or end the drawing of a rectangle.
|
|
is clicked, this function will handle the click and check if the click
|
|
|
|
was within the AOI, in which case it will either start or end the
|
|
|
|
drawing of a rectangle.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
mapRef.current.addListener("click", (event) => {
|
|
mapRef.current.addListener("click", (event) => {
|
|
handleMapClick(event);
|
|
handleMapClick(event);
|
... | @@ -302,11 +254,9 @@ mapRef.current.addListener("click", (event) => { |
... | @@ -302,11 +254,9 @@ mapRef.current.addListener("click", (event) => { |
|
|
|
|
|
### **endDrawing()**
|
|
### **endDrawing()**
|
|
|
|
|
|
This function ends the drawing of a rectangle on the map. It checks if
|
|
This function ends the drawing of a rectangle on the map. It checks if the rectangle is within the AOI and if so, it stores the rectangle for further use.
|
|
the rectangle is within the AOI and if so, it stores the rectangle for
|
|
|
|
further use.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
function endDrawing(endPoint) {
|
|
function endDrawing(endPoint) {
|
|
if (isRectangleInside(rectangle.current, AOI.current)) {
|
|
if (isRectangleInside(rectangle.current, AOI.current)) {
|
... | @@ -327,15 +277,13 @@ endPoint - The end point of the rectangle. |
... | @@ -327,15 +277,13 @@ endPoint - The end point of the rectangle. |
|
|
|
|
|
#### **Output:**
|
|
#### **Output:**
|
|
|
|
|
|
Ends the drawing of the rectangle and either stores it for further use
|
|
Ends the drawing of the rectangle and either stores it for further use or removes it from the map.
|
|
or removes it from the map.
|
|
|
|
|
|
|
|
#### **Use**
|
|
#### **Use**
|
|
|
|
|
|
This function is called when ending the drawing of a rectangle to check
|
|
This function is called when ending the drawing of a rectangle to check if it is within the AOI and handle it appropriately.
|
|
if it is within the AOI and handle it appropriately.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
function handleMapClick(event) {
|
|
function handleMapClick(event) {
|
|
// ...
|
|
// ...
|
... | @@ -348,11 +296,9 @@ function handleMapClick(event) { |
... | @@ -348,11 +296,9 @@ function handleMapClick(event) { |
|
|
|
|
|
### **getSatelliteImages()**
|
|
### **getSatelliteImages()**
|
|
|
|
|
|
This function queries the Google Earth Engine API to get available
|
|
This function queries the Google Earth Engine API to get available satellite images within a given geometry and time range. It returns a list of image objects containing metadata for the images found.
|
|
satellite images within a given geometry and time range. It returns a
|
|
|
|
list of image objects containing metadata for the images found.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
function getSatelliteImages(geometry, startDate, endDate) {
|
|
function getSatelliteImages(geometry, startDate, endDate) {
|
|
var imageList = [];
|
|
var imageList = [];
|
... | @@ -382,9 +328,7 @@ function getSatelliteImages(geometry, startDate, endDate) { |
... | @@ -382,9 +328,7 @@ function getSatelliteImages(geometry, startDate, endDate) { |
|
|
|
|
|
#### **Inputs:**
|
|
#### **Inputs:**
|
|
|
|
|
|
geometry - The geometry to query images within. startDate - The start
|
|
geometry - The geometry to query images within. startDate - The start date of the time range to query. endDate - The end date of the time range to query.
|
|
date of the time range to query. endDate - The end date of the time
|
|
|
|
range to query.
|
|
|
|
|
|
|
|
#### **Output:**
|
|
#### **Output:**
|
|
|
|
|
... | @@ -392,11 +336,9 @@ A list of image objects containing metadata for the images found. |
... | @@ -392,11 +336,9 @@ A list of image objects containing metadata for the images found. |
|
|
|
|
|
#### **Use**
|
|
#### **Use**
|
|
|
|
|
|
This function can be used to query satellite images within a given area
|
|
This function can be used to query satellite images within a given area and time range. The returned list of images can then be used to select images for analysis.
|
|
and time range. The returned list of images can then be used to select
|
|
|
|
images for analysis.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
var images = getSatelliteImages(geometry, "2020-01-01", "2020-12-31");
|
|
var images = getSatelliteImages(geometry, "2020-01-01", "2020-12-31");
|
|
// Use images for selecting images, displaying thumbnails, etc.
|
|
// Use images for selecting images, displaying thumbnails, etc.
|
... | @@ -404,10 +346,9 @@ var images = getSatelliteImages(geometry, "2020-01-01", "2020-12-31"); |
... | @@ -404,10 +346,9 @@ var images = getSatelliteImages(geometry, "2020-01-01", "2020-12-31"); |
|
|
|
|
|
### **maskClouds()**
|
|
### **maskClouds()**
|
|
|
|
|
|
This function masks clouds in a Landsat 8 image using the CFmask band.
|
|
This function masks clouds in a Landsat 8 image using the CFmask band. It returns a new image with the cloudy pixels masked.
|
|
It returns a new image with the cloudy pixels masked.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
function maskClouds(image) {
|
|
function maskClouds(image) {
|
|
var cfmask = image.select("cfmask");
|
|
var cfmask = image.select("cfmask");
|
... | @@ -428,10 +369,9 @@ A new image with the cloudy pixels masked. |
... | @@ -428,10 +369,9 @@ A new image with the cloudy pixels masked. |
|
|
|
|
|
#### **Use**
|
|
#### **Use**
|
|
|
|
|
|
This function can be used to mask clouds in a Landsat 8 image before
|
|
This function can be used to mask clouds in a Landsat 8 image before performing analysis on the image.
|
|
performing analysis on the image.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
var maskedImage = maskClouds(image);
|
|
var maskedImage = maskClouds(image);
|
|
// Use maskedImage for analysis
|
|
// Use maskedImage for analysis
|
... | @@ -439,10 +379,9 @@ var maskedImage = maskClouds(image); |
... | @@ -439,10 +379,9 @@ var maskedImage = maskClouds(image); |
|
|
|
|
|
### **calculateArea()**
|
|
### **calculateArea()**
|
|
|
|
|
|
This function calculates the area of a polygon in square meters. It uses
|
|
This function calculates the area of a polygon in square meters. It uses the Google Maps Geometry library to calculate the area.
|
|
the Google Maps Geometry library to calculate the area.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
function calculateArea(polygon) {
|
|
function calculateArea(polygon) {
|
|
var area = 0;
|
|
var area = 0;
|
... | @@ -466,11 +405,9 @@ The area of the polygon in square meters. |
... | @@ -466,11 +405,9 @@ The area of the polygon in square meters. |
|
|
|
|
|
#### **Use**
|
|
#### **Use**
|
|
|
|
|
|
This function can be used to calculate the area of a polygon. Each point
|
|
This function can be used to calculate the area of a polygon. Each point in the polygon should be an object with x and y properties representing the longitude and latitude of the point.
|
|
in the polygon should be an object with x and y properties representing
|
|
|
|
the longitude and latitude of the point.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
var area = calculateArea(polygon);
|
|
var area = calculateArea(polygon);
|
|
console.log("Area of polygon: " + area + " square meters");
|
|
console.log("Area of polygon: " + area + " square meters");
|
... | @@ -478,10 +415,9 @@ console.log("Area of polygon: " + area + " square meters"); |
... | @@ -478,10 +415,9 @@ console.log("Area of polygon: " + area + " square meters"); |
|
|
|
|
|
### **calculateDistance()**
|
|
### **calculateDistance()**
|
|
|
|
|
|
This function calculates the distance between two points in meters. It
|
|
This function calculates the distance between two points in meters. It uses the Google Maps Geometry library to calculate the distance.
|
|
uses the Google Maps Geometry library to calculate the distance.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
function calculateDistance(point1, point2) {
|
|
function calculateDistance(point1, point2) {
|
|
return google.maps.geometry.spherical.computeDistanceBetween(point1, point2);
|
|
return google.maps.geometry.spherical.computeDistanceBetween(point1, point2);
|
... | @@ -490,8 +426,7 @@ function calculateDistance(point1, point2) { |
... | @@ -490,8 +426,7 @@ function calculateDistance(point1, point2) { |
|
|
|
|
|
#### **Inputs:**
|
|
#### **Inputs:**
|
|
|
|
|
|
point1 - The first point as a google.maps.LatLng object. point2 - The
|
|
point1 - The first point as a google.maps.LatLng object. point2 - The second point as a google.maps.LatLng object.
|
|
second point as a google.maps.LatLng object.
|
|
|
|
|
|
|
|
#### **Output:**
|
|
#### **Output:**
|
|
|
|
|
... | @@ -499,10 +434,9 @@ The distance between the two points in meters. |
... | @@ -499,10 +434,9 @@ The distance between the two points in meters. |
|
|
|
|
|
#### **Use**
|
|
#### **Use**
|
|
|
|
|
|
This function can be used to calculate the distance between two points.
|
|
This function can be used to calculate the distance between two points. Each point should be a google.maps.LatLng object.
|
|
Each point should be a google.maps.LatLng object.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
var distance = calculateDistance(point1, point2);
|
|
var distance = calculateDistance(point1, point2);
|
|
console.log("Distance between points: " + distance + " meters");
|
|
console.log("Distance between points: " + distance + " meters");
|
... | @@ -510,11 +444,9 @@ console.log("Distance between points: " + distance + " meters"); |
... | @@ -510,11 +444,9 @@ console.log("Distance between points: " + distance + " meters"); |
|
|
|
|
|
### **calculateNDVI()**
|
|
### **calculateNDVI()**
|
|
|
|
|
|
This function calculates the Normalized Difference Vegetation Index
|
|
This function calculates the Normalized Difference Vegetation Index (NDVI) for a given image. It uses bands 4 (Red) and 5 (Near Infrared) to calculate the NDVI.
|
|
(NDVI) for a given image. It uses bands 4 (Red) and 5 (Near Infrared) to
|
|
|
|
calculate the NDVI.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
function calculateNDVI(image) {
|
|
function calculateNDVI(image) {
|
|
var nir = image.select("B5");
|
|
var nir = image.select("B5");
|
... | @@ -534,10 +466,9 @@ The image with the NDVI band added. |
... | @@ -534,10 +466,9 @@ The image with the NDVI band added. |
|
|
|
|
|
#### **Use**
|
|
#### **Use**
|
|
|
|
|
|
This function can be used to calculate the NDVI for a given image. The
|
|
This function can be used to calculate the NDVI for a given image. The image should be a Landsat 8 image.
|
|
image should be a Landsat 8 image.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
var ndviImage = calculateNDVI(image);
|
|
var ndviImage = calculateNDVI(image);
|
|
// Use ndviImage for analysis
|
|
// Use ndviImage for analysis
|
... | @@ -545,11 +476,9 @@ var ndviImage = calculateNDVI(image); |
... | @@ -545,11 +476,9 @@ var ndviImage = calculateNDVI(image); |
|
|
|
|
|
### **calculateShoreline()**
|
|
### **calculateShoreline()**
|
|
|
|
|
|
This function calculates the shoreline of a given image by thresholding
|
|
This function calculates the shoreline of a given image by thresholding the NDVI and applying a morphological operation to remove small islands and fill small holes.
|
|
the NDVI and applying a morphological operation to remove small islands
|
|
|
|
and fill small holes.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
function calculateShoreline(image) {
|
|
function calculateShoreline(image) {
|
|
var ndvi = image.select("NDVI");
|
|
var ndvi = image.select("NDVI");
|
... | @@ -569,10 +498,9 @@ The image with the shoreline band added. |
... | @@ -569,10 +498,9 @@ The image with the shoreline band added. |
|
|
|
|
|
#### **Use**
|
|
#### **Use**
|
|
|
|
|
|
This function can be used to calculate the shoreline for a given image.
|
|
This function can be used to calculate the shoreline for a given image. The image should be a Landsat 8 image with an NDVI band.
|
|
The image should be a Landsat 8 image with an NDVI band.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
var shorelineImage = calculateShoreline(ndviImage);
|
|
var shorelineImage = calculateShoreline(ndviImage);
|
|
// Use shorelineImage for analysis
|
|
// Use shorelineImage for analysis
|
... | @@ -580,10 +508,9 @@ var shorelineImage = calculateShoreline(ndviImage); |
... | @@ -580,10 +508,9 @@ var shorelineImage = calculateShoreline(ndviImage); |
|
|
|
|
|
### **getPolygonArea()**
|
|
### **getPolygonArea()**
|
|
|
|
|
|
This function calculates the area of a polygon in square kilometers. It
|
|
This function calculates the area of a polygon in square kilometers. It uses the Google Earth Engine API to calculate the area.
|
|
uses the Google Earth Engine API to calculate the area.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
function getPolygonArea(polygon) {
|
|
function getPolygonArea(polygon) {
|
|
return ee.Geometry(polygon).area().divide(1000000);
|
|
return ee.Geometry(polygon).area().divide(1000000);
|
... | @@ -592,8 +519,7 @@ function getPolygonArea(polygon) { |
... | @@ -592,8 +519,7 @@ function getPolygonArea(polygon) { |
|
|
|
|
|
#### **Inputs:**
|
|
#### **Inputs:**
|
|
|
|
|
|
polygon - The polygon to calculate the area of, as an ee.Geometry
|
|
polygon - The polygon to calculate the area of, as an ee.Geometry object.
|
|
object.
|
|
|
|
|
|
|
|
#### **Output:**
|
|
#### **Output:**
|
|
|
|
|
... | @@ -601,10 +527,9 @@ The area of the polygon in square kilometers. |
... | @@ -601,10 +527,9 @@ The area of the polygon in square kilometers. |
|
|
|
|
|
#### **Use**
|
|
#### **Use**
|
|
|
|
|
|
This function can be used to calculate the area of a polygon. The
|
|
This function can be used to calculate the area of a polygon. The polygon should be an ee.Geometry object.
|
|
polygon should be an ee.Geometry object.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
var area = getPolygonArea(polygon);
|
|
var area = getPolygonArea(polygon);
|
|
console.log("Area of polygon: " + area + " square kilometers");
|
|
console.log("Area of polygon: " + area + " square kilometers");
|
... | @@ -612,10 +537,9 @@ console.log("Area of polygon: " + area + " square kilometers"); |
... | @@ -612,10 +537,9 @@ console.log("Area of polygon: " + area + " square kilometers"); |
|
|
|
|
|
### **getPolygonPerimeter()**
|
|
### **getPolygonPerimeter()**
|
|
|
|
|
|
This function calculates the perimeter of a polygon in kilometers. It
|
|
This function calculates the perimeter of a polygon in kilometers. It uses the Google Earth Engine API to calculate the perimeter.
|
|
uses the Google Earth Engine API to calculate the perimeter.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
function getPolygonPerimeter(polygon) {
|
|
function getPolygonPerimeter(polygon) {
|
|
return ee.Geometry(polygon).perimeter().divide(1000);
|
|
return ee.Geometry(polygon).perimeter().divide(1000);
|
... | @@ -624,8 +548,7 @@ function getPolygonPerimeter(polygon) { |
... | @@ -624,8 +548,7 @@ function getPolygonPerimeter(polygon) { |
|
|
|
|
|
#### **Inputs:**
|
|
#### **Inputs:**
|
|
|
|
|
|
polygon - The polygon to calculate the perimeter of, as an ee.Geometry
|
|
polygon - The polygon to calculate the perimeter of, as an ee.Geometry object.
|
|
object.
|
|
|
|
|
|
|
|
#### **Output:**
|
|
#### **Output:**
|
|
|
|
|
... | @@ -633,10 +556,9 @@ The perimeter of the polygon in kilometers. |
... | @@ -633,10 +556,9 @@ The perimeter of the polygon in kilometers. |
|
|
|
|
|
#### **Use**
|
|
#### **Use**
|
|
|
|
|
|
This function can be used to calculate the perimeter of a polygon. The
|
|
This function can be used to calculate the perimeter of a polygon. The polygon should be an ee.Geometry object.
|
|
polygon should be an ee.Geometry object.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
var perimeter = getPolygonPerimeter(polygon);
|
|
var perimeter = getPolygonPerimeter(polygon);
|
|
console.log("Perimeter of polygon: " + perimeter + " kilometers");
|
|
console.log("Perimeter of polygon: " + perimeter + " kilometers");
|
... | @@ -644,10 +566,9 @@ console.log("Perimeter of polygon: " + perimeter + " kilometers"); |
... | @@ -644,10 +566,9 @@ console.log("Perimeter of polygon: " + perimeter + " kilometers"); |
|
|
|
|
|
### **calculateCoastalSqueeze()**
|
|
### **calculateCoastalSqueeze()**
|
|
|
|
|
|
This function calculates the coastal squeeze for a given image. It uses
|
|
This function calculates the coastal squeeze for a given image. It uses the shoreline and mangrove bands to calculate the squeeze.
|
|
the shoreline and mangrove bands to calculate the squeeze.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
function calculateCoastalSqueeze(image) {
|
|
function calculateCoastalSqueeze(image) {
|
|
var shoreline = image.select("Shoreline");
|
|
var shoreline = image.select("Shoreline");
|
... | @@ -667,13 +588,12 @@ The image with the coastal squeeze band added. |
... | @@ -667,13 +588,12 @@ The image with the coastal squeeze band added. |
|
|
|
|
|
#### **Use**
|
|
#### **Use**
|
|
|
|
|
|
This function can be used to calculate the coastal squeeze for a given
|
|
This function can be used to calculate the coastal squeeze for a given image. The image should have shoreline and mangrove bands.
|
|
image. The image should have shoreline and mangrove bands.
|
|
|
|
|
|
|
|
``` javascript
|
|
```javascript
|
|
|
|
|
|
var squeezeImage = calculateCoastalSqueeze(image);
|
|
var squeezeImage = calculateCoastalSqueeze(image);
|
|
// Use squeezeImage for analysis
|
|
// Use squeezeImage for analysis
|
|
```
|
|
```
|
|
|
|
|
|
<hr> |
|
--- |
|
|
|
\ No newline at end of file |