Skip to content

RM503/Regen_analytics_app

Repository files navigation

Static Badge License AWS

Regen Organics analytics app

What is this app for?

This is an analytics web application designed by a group of volunteers at DataKind for Regen Organics, serving two primary purposes:

  • Generate and store key statistics related to planting cycles and crop growth using vegetation indices (NDVI and NDMI) with the help of Google Earth Engine (GEE) and Supabase backends
  • Serve as an analytics dashboard containing data and visualizations from initial market data, pre-existing analyses and trained models. The app also includes functionalities for inserting newly queried farm polygons for analyses and visualizations (only available for authenticated users).

The design and functionality of this app relies heavily on the workflow carried out during the research phases of the project - which included extensive planning, data generation, visualization, ETL and ML model training. The codebase can be accessed through the following link:

https://github.com/RM503/DataKind_Geospatial

Even though the app was designed for a particular organization, it can be adapted to the needs of other users. Details on API requirements are provided later in this document.

Building and running the app

The complete list of libraries required for running the app can be found in the requirements.txt or pyproject.toml files. To adapt the app for similar agricultural use cases, please clone the repository to your local device using

git clone https://github.com/RM503/Regen_analytics_app.git

After the required confifurations are done for the particular use case, it can be run as Docker containers. The app is first built as

docker build -t <whatever_name_you_want:version> .

and run

docker run --env-file .env.docker -p 8080:8080 <whatever_name_you_want:version>

In the run command, the environment variables are explicitly injected using the .env.docker file. A prebuilt image can also be found in Docker Hub and pulled using

docker pull rmahbub503/regen_organics_analytics_app:v1

After the preceding steps have been completed, the app can be run locally. The app, at the moment, uses the following APIs and services

  • Google Earth Engine (GEE) Python API for calculating NDVI-NDMI curves from queried polygons
  • iSDA API for extracting soil quantities for queried polygons
  • Supabase for SELECT and INSERT operations pre-existing and storing newly queried data

These services have their own API keys and URLs, which need to be provided for the app to work. The following is a skeleton for what the .env file should look like

GEE_PROJECT=... 
GOOGLE_APPLICATION_CREDENTIALS=...
EE_SERVICE_ACC_EMAIL=...
ISDA_USERNAME=...
ISDA_PASSWORD=...
SUPABASE_URL=...

An template is also found in .env_template. For a complete set of instructions on how to use the app, please check the docs folder.

Access through AWS Elastic Beanstalk

A test deployment of the app currently exists in AWS Elastic Beanstalk as well-

http://regen-app-test.eba-btqhah9s.us-east-1.elasticbeanstalk.com/

The app is currently being deployed from the us-east-1 region. Hence, access from a region other than this will possibly introduce latency.

How to use this app?

The app is divided into multiple dashboards, each serving different purposes. This can be seen upon launching the app, taking the user to the landing page. The following contains detailed information regarding each dashboard:

  • Initial Market Data: This dashboard contains exploratory data analysis using initial sales and leads data provided by Regen Organics.

  • Polygon Generator: This dashboard contains an interactive tile map which the user can leverage to explore regions of interest in Kenya, identify farms (through coordinate searches) and draw polygons around them. Once a polygon is drawn, information on it will be generated, which contain a unique identifier (uuid), area in acres and polygon geometry. Note, however, that the app will only allow a maximum of five polygons to be queried at a given time before refreshing.

  • Farmland Characteristics: User(s) can use the polygons generated in the previous dashboard to obtain NDVI-NDMI time series curves. These indices are extremely important for assessing crop/vegetation health and moisture levels. Furthermore, this dashboard also yields tabulated data that returns information on peak crop growing seasons, number of planting cycles, moisture levels and important soil characteristics.

  • Farmland Statistics: This dashboard contains analyses results obtained from the research phase of the project, containing region-aggregated statistics on various metrics that have been deemed important for the project. Importantly, this dashboard can be used as a means of comparing farmland performance of various distributor locations. Newly acquired data are also refreshed into the dashboard through PostgreSQL triggers.

As noted earlier, INSERT operations can only be performed by authenticated users. Currently, UPDATE and DELETE operations can only be performed by users with administrative access to Supabase.

How to contribute

If you are interested in contributing to the app to extend/improve its design, functionality or scope, please do the following:

  • Fork the repository
  • Create a branch (git checkout -b feature-name)
  • Make your changes and submit a pull request

Contact

For questions or suggestions regarding the app, please contact Rafid Mahbub ([email protected]) or Sheldon Waugh ([email protected]).