@@ -8,7 +8,7 @@ The Normalized Difference Vegetation Index (NDVI) is a critical measure for eval
This project aims to calculate the average NDVI for Argentina using AWS Step Functions to orchestrate parallel processing. The workflow involves reading NDVI images from an S3 bucket, calculating the mean NDVI, and then providing options to save the results in various formats.
The NDVI images, sourced from the 'ndvi-satellite-images' S3 bucket, are provided by NASA satellites with a resolution of 256x256 pixels, representing bi-weekly NDVI values. Image filenames follow the "argentina_date.tif" pattern, with dates formatted as a four-digit year followed by a three-digit day of the year.
The NDVI images, sourced from the 'ndvi-satellite-images' S3 bucket, are provided by NASA satellites, representing bi-weekly NDVI values. Image filenames follow the "argentina_date.tif" pattern, with dates formatted as a four-digit year followed by a three-digit day of the year.
...
...
@@ -60,32 +60,31 @@ The following image represent the application workflow. Each step in the flowcha

#### Step 1: Create State Machine
Log into the AWS Management Console and navigate to the AWS Step Functions page.
Click on Create state machine to start the process of creating your workflow template.
#### Step 2: Design Workflow Visually
Choose **Design your workflow visually** to open the visual workflow editor. This option allows you to construct your state machine using a drag-and-drop interface.
#### Step 3: Choose State Machine Type
Select the **Standard** type for the state machine. If unsure about which type to select, click on Help me decide for a detailed comparison between **Standard** and **Express** types.
After selecting the type, click Next to proceed to the workflow studio.
#### Step 4: Use Flow Control
* Log into the AWS Management Console and navigate to the AWS Step Functions page.
* Click on Create state machine to start the process of creating your workflow template.
* Choose **Blank** to create a workflow from scratch.
Inside the workflow studio, navigate to the left-hand panel and select **Flow** control.
Choose **Map**, which allows for parallel processing. Note that based on your workflow, you might not need to use Map if there's no parallel processing required.
#### Step 5: Configure a state to compute NDVI mean
Drag and drop AWS Lambda from the Actions panel to add a task to invoke your Lambda function.
Configure the task with the name of the Lambda function that computes the mean. Set the Payload option to use the state's input as the payload for the Lambda function.
#### Step 6: Add Choice Flow
Drag and drop the Choice state onto your workflow to create a branching logic.
Configure the Choice state by adding rules:
* Click Add new rule.
* Set a condition by choosing the variable $.type.
* For the operator, select is exactly and set the value to a String constant of "CSV" for the first condition.
* Repeat the process for the second rule and set the value to "PNG".
#### Step 7: Configure Lambda Tasks for the Condition
Under each condition you've set in the Choice state, you will add the respective Lambda tasks:
For CSV, drag another Lambda function onto the workflow and configure it to invoke the function that processes the data and outputs it to a CSV file.
For PNG, do the same for the Lambda function that processes the data and outputs it to a PNG file.
#### Step 8: Save and Test
Once all the states are configured correctly, Save the state machine.
Test your state machine by starting an execution and monitoring the results to ensure that it behaves as expected.
* Choose **Map**, which allows for parallel processing. To read the images from S3 bucket and compute the NDVI mean. Configure the 'Map' state:
* Assign a suitable name
* Select the processing mode as 'Distributed,' facilitating the creation of separate child workflows for each image.
* Choose the item source as 'Amazon S3,' then select 'S3 object list' as the S3 item source. Navigate to the S3 bucket 'ndvi-satellite-images,' where the NDVI images are stored.
* Navigate to the output panel and select 'Add original input to output using ResultPath'.
* Drag and drop AWS Lambda from the Actions panel to add a task to compute the mean of NDVI. Configure:
* Assign a name to the state.
* Within the 'API Parameters' section, select 'Enter function name' to trigger the previously created lambda function responsible for computing the mean. Input the ARN (Amazon Resource Name) of the function accordingly.
* Drag and drop the 'Choice' state from the Flow panel.
* Configure the Choice state by adding rules:
* Set Rule #1.
* Define a condition based on the variable $.type.
* Select 'is equal to' as the operator and set the value to a String constant of "CSV".
* Within the 'CSV' condition set in the Choice state, include the Lambda function which generates output data in CSV format.
* Additionally, under the 'default' condition, include the Lambda function which generates output data in PNG format.
* Once all the states are configured correctly, Create the state machine.
* Test your state machine by starting an execution and monitoring the results to ensure that it behaves as expected.