# Topdressing Nitrogen Demand Prediction in Rice Crop Using Machine Learning Systems
## 4 Data Ingestion
### Inundation Mapping and Seeding Date Determination  
The seeding date was determined through the detection of fields' inundation, as seeding follows shortly after rice fields' inundation. The inundations were mapped with Computer Vision techniques applied on Synthetic Aperture Radar (SAR) images acquired from Sentinel-1 satellites (for the years 2018-2019) [26; 27]. However, the growers in some cases, according to the levels of infestation by the red rice (Oryza punctate), use a weed suppressive period following an early inundation of the field. Hence, critical for the scopes of the MLS approach used in this study was to identify this period, which can be called \"pseudo-seeding\". Therefore, if the first inundation was followed by a short fallow period, the seeding date was considered the date of the second inundation. Inundation mapping was carried out by classifying land into 2 exclusive classes (WATER vs. NO-WATER). Sentinel-1 products were chosen for inundation mapping because they offer medium-to-high-resolution imaging in all weather conditions, due to the C-SAR sensor mounted on the satellites. Sentinel-1 images are acquired every 6 days by a two-satellite constellation, with the prime objectives of Land and Ocean monitoring. A total of 14 Sentinel-1 image scenes covering the study fields in the Plain of Thessaloniki from the 2018 and 2019 rice cropping seasons were acquired; the exact dates were: 18 May 2018, 5 June 2018, 23 June 2018, 23 July 2018, 10 August 2018, 22 August 2018, 15 September 2018, 25 May 2019, 31 May 2019, 12 June 2019, 18 July 2019, 5 August 2019, 29 August 2019, and 22 September 2019. The first acquisition dates correspond to several weeks before the normal commencement of the rice period in Thessaloniki; N topdressing normally takes place at the end of June for rice seeded in May. First, SNAP-ESA software was used to edit the Sentinel-1 imagery for calibration, speckle filtering, and terrain correction. Then, QGIS software was used to create the \"Areas of Interest\" (AOIs) according to the training field data. Finally, the edited images were masked with the AOIs, thus creating the required clipped image subsets for the analysis (Figure 4). To facilitate the whole process of image subset preparation, a script was written in Python programming language. Figure 3: Indicative subset of the delineated management zones and the respective soil sample locations (central sector of the rice farm, 56 ha; background: RapidEye composite image of 2015). The image data were analyzed with Computer Vision using a Convolutional Neural Network (CNN). According to [PERSON] (2012) [28], Computer Vision is the automated extraction of information from images. The Computer Vision problems most commonly use Convolutional Neural Networks (CNNs), a class of Deep Neural Networks that are widely used in image recognition and image classification because they are capable of discovering the relevance in contextual features [29]. The architecture of network construction was to include three 2D convolution layers that were activated with the ReLU function. A dense layer activated with the ReLU function was used to connect all the neurons which ended up in the final neuron that conducted the categorization. This final neuron is activated with the sigmoid function. The CNN was trained in 7 epochs and with 10 steps per epoch, as after many trials these attributes yielded the best result without overfitting the data in the model. Samples for training and validation of the CNN were collected with field surveys on the same dates of the Sentinel-1 images and consisted of 280 image subsets (polygons) covering wetlands and rice fields. Part of these subsets (210 samples) were used for training the model, while the rest (70 samples) were used for validation. From the training samples, half corresponded to WATER class and half corresponded to NO-WATER class. The model achieved a precision of 0.92, a recall of 0.93 and a F1-score of 0.92 for the WATER class.