Skip to content

A historical version of the user-friendly ETL tool we developed to streamline the UAV data pipeline of the highly funded research project Phenocrop, during our 2024 summer job.

License

Notifications You must be signed in to change notification settings

SindreStokke/Phenocrop-UAV-Data-Processing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phenocrop UAV Data Processing Program

The "Phenocrop UAV Data Processing Program" is a software written in Python to help the drone pilots (and eventually the researchers) manage all aspects of the pipeline, including weekly overview of data collection, data transfer and processing and analysis. In the big perspective, the purpose of this drone-based project is to systematically collect agricultural data to support scientific research. This program aims to standardize data collection and enhancing repeatability. By automating the data collection process, we will eliminate as much manual error as possible. This automation ensures consistency and reliability in data collection, transfer and processing, which is critical for longitudinal studies.

Preview

Add drone flights

The "Add drone flights" page looks like this, and is used to import all data from the UAV memory card into the correct locations on the computer or server:

Screenshot-add-drone-flights

Review drone flights

The "Review drone flights" page looks like this:

Screenshot-review-drone-flights

Analyze fields

The "Analyze fields" page looks like this:

Screenshot-analyze-fields

Flight details

The "Flight details" page looks like this:

Screenshot-flight-details

Data

Data Pipeline

Step 1: The data handling pipeline starts with the transfering from the SD cards. Use the user interface or the filetransfer.py script. The program expects folders with the given naming structure from DJI Mavic or DJI Matrice. The program can handle one flight route with the phantom drone, but this is hard coded and needs to be updated for futher use. The transfering script gives some simple editing option; discard/trash a folder, move a folder, duplicate a folder. The transfering script needs some inputs. A input path to the SD cards, output path, logic csv file path, and a log file path. The logic file is a csv that connects a flightname with a location and some settings. This needs to be made before the transfer, and only needs to be done once for each flight route.

Step 2: The next step is the image stitcing. All the drone images needs to be striched together so we can tell the different trail plots apart. Pix4d has been the app used to acomplish this. Other options needs to be looked for more pythonintergrated solutions (OpenDrone map, Pix4d Engine). These app take the raw drone images as input and produse one orthomosaic reflectanse map for each band as output for the multispectral data and one DSM(Digital surface model) orthomosaic for the 3D data. In this step we also calibrate the drone images with the reflectanse panel for the multispectral data.

Pix4d: (if pix4d is used have the drone data localy in the C: drive and create and prosess the data locally then transfer them to the nmbu server after the prosess is finiched. This will save a lot of time)

Step 3: Value extraction for each trail plot. This step takes the otrhomosaics from step 2 and a polygon as input. The polygon is a mask of the field where all the trail plot is marked with its uniqe field ID. The polygons needs to be meda each season and this can be done i the QGIS software. To extrackt the polygon mask from the orthomosaic we can use QGIS, Python, R-script, the values we are interested in and want as output is: Median, Mean, Standard diviation for the multispectral data and DSM-DTM for the 3D data. For all the values extracted we need a corresponding field ID to make any sense of the data.

Drone Data

Dependent on the drone the file structure is different. The most used DJI Mavic 3 pro saved the data DJI_xxxxxxxxxxxx_001_name-of-flight, where the x represent the date and time. The DJI Phantom 4 saves the data folder as 101FPLAN.

When the name-of-flight is set, it should contain key information: name of the field, what kind of data that is collected MS for multispectral, and Horizontal or Vertical or Both depentend on the route settings, and the height. All this should be included in the name of the flight.

The naming of the folders should follow a set structure: yyyymmdd FIELD_NAME DRONE Height DATATYPE Sideverlap Frontoverlap

The first 8 characters is the timestamp, the next is the name of the field, the height should have m behide to be presice (20m), the DATATYPE should be MS or 3D, and last the overlap should be ff ss (where ff is the front overlap, and ss is the side overlap). The Delimiter between is a whitespace.

To ensure that the data contant is correct all data should be transfered using the filetransfer.py script for the data collected for DJI Mavic 3 pro, DJI Matrice 300, and the Phantom 4. The logic in the script depends on the flight name to sort them. If there are multiple fields that need data captured by Phantom 4 drones the data needs to be handled manually or the code needs to be updated.

CSV Data

Entity-Relationship Diagram of the CSV Data:

ERD of CSV data

This diagram shows the columns contained in each csv file and which columns are used to merge their dataframes together. The columns in gray are not yet created, but suggested for the future to expand the functionality of the Phenotyping GUI.

  • 🔑 means that each entry (row) in that given column is a unique identifier.
  • 🗝 means that each entry (row) in that column is equal to some entry in the connected column of the other csv file.

Procedure to run the program

First-time setup

Install “Anaconda Navigator” if it is not installed. Miniconda might also be sufficient. Clone the repository or download a zip file and unzip it. Create a python environment from the file Pheno.yml by using the command: conda env create -f Pheno.yml -n Pheno PS: during installation you might be prompted to give administrator rights. This is not necessary and is only to put a shortcut in the start menu, we think.

Setup the prompt

Start “Anaconda Prompt” Activate the environment by the command: conda activate Pheno PS: you can check which environments exist by the command: conda info --envs Set the current path to the folder of the downloaded repository. E.g: P:\PhenoCrop\Test_Folder\Test_SINDRE\Git_repo\UAV-Data-Processing

Start the program

Do the “Setup the prompt” procedure twice, so that you get two “Anaconda Prompt” windows. In one “Anaconda Prompt” window you write: streamlit run St_Phenotyping.py PS: the browser window which then appears is the browser window you are going to use as the Phenotyping GUI. If you accidentally close it, the URL for it should still show in the Anaconda Prompt window, and it should be: http://localhost:8501 In the other “Anaconda Prompt” window you write: streamlit run St_flight_details.py PS: the browser window which then appears will contain an error. This is fine and you can close this window after it has opened. It is just so that it runs in the background and is used when the user clicks to see details of a flight.

Start the processing status script (optional)

Do the “Setup the prompt” procedure Write: streamlit run modules/processing_status.py PS: this might take some seconds to run (5-120s) as it is going through all the flights and checking the processing status of each.

Additional tips

  • The Phenotyping GUI best supports dark mode, as some text on the page “Review Drone Flights” (St_review_flights.py) is hardcoded white, and therefore becomes invisible when run in light mode.
  • A comprehensive list of packages and version numbers can be found in the file Pheno.yml. However, the main packages are: pandas, streamlit, matplotlib.pyplot and seaborn.
  • If the “Add drone flights” page gets stuck loading, you can check the terminal for error message. The likely cause is that some of the folders in the memory card’s “DCIM” folder, lacks an entry in flight_routes.csv. In that case, you may solve the problem by adding it.
  • The file St_Phenotyping.py is the top node of the file structure. This is the page that references all the other streamlit pages and makes the navigation panel which links to them.

The code to preprocess (import, format and merge) the csv files into pandas dataframes is located in modules/flight_log_preprocessing.py. This module is imported into every python file that needs access to the data, by the following code (usually located at the top of the file):

from modules.flight_log_preprocessing import preprocessing
df_flight_log, df_flight_routes, df_fields, df_flight_log_merged, df_processing_status = preprocessing()

About

A historical version of the user-friendly ETL tool we developed to streamline the UAV data pipeline of the highly funded research project Phenocrop, during our 2024 summer job.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •