2020 Agtech Challenge: crop classification using satellite images
Introduction
The Sadosky Foundation promotes the use of data-driven solutions by inviting companies to bring their real-life problems to the data science community. They periodically organize competitions in which participants must solve these problems using machine learning techniques.
In December 2020, together with Melina Dalessandro, we won the Agtech 2020 Challenge. In this post we present our solution.
Problem
Participants must build a supervised machine learning model that, using satellite images and ground truth from previous crop seasons, can classify crops for different geographical locations in the department of General López, Santa Fé.
The official website of the competition is avalable here. The Data (train and test) is available here. The table with the scores is here. Our roposed solution is avaliable here
Proposed solution
We used both R and Python. The data pre-processing was conducted with R and the modeling with Python, so it is necessary to have both programs to be able to replicate the whole process. It is necessary to have installed the following libraries:
R libraries: tidyverse, sf y raster.
Python libraries: pandas, numpy, pyreadr, sklearn, tensorflow, keras y os.
Data
Different transformations were applied to the train dataset:
Data augmentation. To increase the amount of data we took points around the training points.
The Sentinel-2 satellite bands 2 (blue), 3 (green), 4 (red), 8 (nir) and 11 (swir) were extracted for each point (original and augmented datasets) for all dates with low cloud presence between 2018-10-04 and 2019-07-06, in the case of the 2018/2019 crop season, and 2019-09-14 to 2020-07-25, in the case of the 2019/2020 crop season. There were 17 and 20 images for each campaign respectively.
The variables/bands ndwi, ndvi, evi, PSSRb1 (pigment specific simple ratio B1), barren_soil and savi were generated from the aforementioned bands.
Linear interpolation and loess were performed on a daily basis to fill missing observatio (due to presence of clouds). We adopten ten day period for the loess.
Cities and bodies of water were extracted using GIS layers from the Argentina’s National Geographic Institute.
Data augmentation
Data augmentation in data analysis are techniques used to increase the amount of data by adding slightly modified copies of already existing data or newly created synthetic data from existing data. It acts as a regularizer and helps reduce overfitting when training a machine learning model.
This was a recommendation suggested by Alfredo Campos in his webinar ([available here)(https://www.youtube.com/watch?v=Nz01C2VT1MI)).
In this case we increased the number of observations by taking points at a distance of 50 and 100 metres around the original train observation (see Figure below). This allows us to capture more variability within the land plots.
Augmented points for crop seasons 18/19 and 19/20
Images and indexes
Bands 2 (blue), 3 (green), 4 (red), 8 (nir) and 11 (swir) were extracted for each point (original and augmented) from the Sentinel-2 satellite for all dates with low presence of cloud for the period between 2018-10-04 and 2019-07-06 in the case of the 2018/2019 crop season, and between 2019-09-14 to 2020-07-25, in the case of the 2019/2020 crop season. There were 17 and 20 images for each crop season respectively.
The variables/bands NDWI, NDVI, EVI, PSSRb1 (pigment specific simple ratio B1), barren_soil and SAVI were generated from the aforementioned bands.
Figure 1 shows the evolution of the median EVI for the different classes of the data set. As can be seen, the dynamics of these variables differs among classes. This is the key to classify the crops.
Figure 1: Evolution of the EVI index for the different classes of the dataset
Given that the presence of clouds prevented us from getting reliable data on some dates, the missing information was filled by applying two interpolation techniques: a linear method and a loess interpolation method.
Figure 2 shows the evolution of the median EVI with loess interpolation every 10 days since October 1st of each year.
Figure 2: Evolution of EVI using loess interpolation
Figure 3 shows the evolution of the median EVI using linear interpolation every 10 days since October 1st of each year.
Figure 3: Evolution of EVI using linear interpolation for the different classes of the dataset
Models
Our best model was a feed forward neural network with two dense layers. We also used a CART model for a small sample of observations (55 points) for which we did not have all the variables needed to use the neural network.
We used the library keras to train the neural network.
The feedforward neural network was the first and simplest type of artificial neural network devised.In this network, the information moves in only one direction—forward—from the input nodes, through the hidden nodes and to the output nodes. There are no cycles or loops in the network.
We trained a NN with two dense layers (256 nodes each) and using “relu” as activation function. In the final layer we used sofmax as the activation function.
The reproducible code is available here.