Soil Classification Based on Deep Learning Algorithm and Visible Near-Infrared Spectroscopy

School of Geosciences, China University of Petroleum (East China), Qingdao 266580, China Institute of Oceanographic Instrumentation, Qilu University of Technology (Shandong Academy of Sciences), Qingdao 266061, China Shandong Technological Center of Oceanographic Instrument, Qingdao 266061, China College of Computer Science and Technology, China University of Petroleum (East China), Qingdao 266590, China College of Ocean Science and Engineering, Shandong University of Science and Technology, Qingdao 266590, China


Introduction
Land cover is a direct result of the interaction between natural environment and human activities. It mainly focuses on describing the natural properties of the earth's surface which has specific time and space characteristics. Changes in land cover will cause the changes in the climate and environmental characteristics, which has an important influence on the social economy and ecosystem [1,2]. e main form of land cover is different types of soil, including cultivated lands, woodlands, grasslands, and bare lands. erefore, it is of great significance to classify different types of soil quickly and accurately for land cover research, soil investigation, and mapping. e early classification method is the land use topographic map obtained by combining with the actual ground survey. Now the classification technology of the remote sensing image is mostly used to realize the classification of different types of soil [3][4][5]. Visible and near-infrared spectroscopy technology is a fast, nondestructive measurement method. It has been widely used in medicine, agriculture, oil, and other fields [6][7][8][9]. e spectral analysis method indirectly obtains useful information of the substance.
rough establishing an effective correction model between the spectrum and the information, the result is obtained [10][11][12]. e spectral technology is introduced into the classification of soil, the remote sensing image information is replaced by the spectral information, and different types of soil models are established. It can be fast and nondestructive to realize the classification of soil.
Deep learning is modeled by simulating the neural structure of the human brain and has made breakthroughs in applications such as image recognition and speech recognition [13,14]. e commonly used classification method support vector machine (SVM) is a machine learning method based on statistical learning theory. e idea behind SVM is that input samples are projected from low-dimensional feature space to high-dimensional space through nonlinear mapping, which allows data in the low-dimensional space that is not linearly separable to transform into linearly separable data in the high-dimensional space [15,16]. While deep learning is to transform the original signal layer by layer, transform the feature representation in the original space to the new feature space. And it automatically learns to get the hierarchical feature representation, and the classification result is achieved [17]. Convolution neutral network (CNN) is a network structure in the deep learning, which has a good effect in the classification of images and makes the CNN method widely used in many fields [18,19]. CNN is a new and nondestructive method for the application of quality monitoring of agricultural products, includes the detection and grading of fruits, vegetables, etc., and has achieved good results [20,21]. CNN is usually used for classification modeling with large sample size.
Based on the visible near-infrared spectroscopy technology, this paper took six different types of soil orchards, woodlands, tea plantations, farmlands, bare land, and grasslands in Qingdao, China, as examples, and established a convolutional neural network classification model. e classification results under the conditions of different label samples were analyzed, and the classification results with the shallow network SVM were compared. In this paper, the aim is to analyze the feasibility of land cover classification with small samples by CNN and explore new methods for rapid, nondestructive, and accurate classification of soil according to the CNN.

Experimental Materials.
Ten sampling points were collected from Licang District, Laoshan District, Chengyang District, and Jiaozhou District, Qingdao, China. e sampling points selected are the areas with consistent color and vegetation coverage, and the spatial distribution of each sampling point was relatively uniform. e basic overview of each sampling point is shown in Table 1. When sampling, a shovel was used to take 0-20 cm of surface soil, and about 1 kg of each soil sample was collected. en it was put in a sealed bag and the label was stuck. It was brought back to the lab, air-dried, and ground, and it was passed through 0.45 mm nylon sieve. Finally, it was put into the sealing bag, a number was made, and it was marked for subsequent testing. e collected soil samples were divided into orchards (S1 and S2), woodlands (S3, S5, and S8), tea plantations (S4), farmlands (S6 and S9), bare lands (S7), and grasslands (S10), as shown in Table 1. ere were 26 orchards soil samples, 86  woodlands soil samples, 13 tea plantations soil samples, 73  farmlands soil samples, 13 bare lands soil samples, and 60  grasslands soil samples, totaling 271 soil samples. e contents of total carbon (TN), total phosphorus (TP), and total potassium (TK) in six types of soil were measured. e average contents of TN, TP, and TK in each type of soil are shown in Table 2, and the nutrient contents of each type of soil are different.

Spectrum Acquisition.
e spectrum of soil samples was collected by QE-65000 spectrometer of ocean optics. Dh-2000 of ocean optics was used as the light source, and the QE-65000 spectrometer of ocean optics (slit 10 µm) was connected by Y-type optical fiber of ocean optics. A set of spectral acquisition system for soil nutrients was built ( Figure 1). e contact end of the optical fiber and the sample was fixed by the probe bracket, keeping the incident light 45°. Under the bracket was a self-made sample box, where a spherical sample slot that coincided with the fiber inlet of the bracket was designed to hold approximately 1-2 g soil samples.
rough this spectrum sampling system, the sampling interval of the collected spectrum was 1 nm, and the integration time was 600 ms. e spectrum range was 200-1100 nm. Each soil sample was measured for 5 times, and the average spectral reflectance was taken. Because the noise in the front and back part of the reflection spectrum had a great influence, the spectrum data of 226-975 nm were retained. e average reflection spectrum of the soil samples of orchards, woodlands, tea plantations, farmlands, bare land, and grasslands are shown in Figure 2. e overall trend of the six types of soil was consistent, and the reflection spectrum increased with the increase in wavelength. But the reflection spectrum of the six types of soil was different.

Kennard-Stone
Algorithm. Based on the Euclidean distance between two samples, the Kennard-Stone algorithm (K-S algorithm) realizes the sample partition selection with strong representativeness and uniform distribution range [22,23]. In this paper, the algorithm is used to classify and select the representative calibration set and test set. e process of Kennard-Stone algorithm is as follows: (1) calculate the Euclidean distance between the two samples, select the samples with the largest Euclidean distance (more than 2); (2) calculate the Euclidean distance between the remaining samples and the selected samples in Step (1); (3) for each remaining sample, select the samples with the shortest distance from the selected samples and then select the samples corresponding to the relative longest distance among the shortest distances; and (4) repeat Step (3) until the number of selected samples is greater than or equal to the set value.

Deep Learning Algorithm.
In 2006, the concept of deep learning was first proposed by Hinton [24]. Its main point is that multihidden layer artificial neural network has excellent feature learning ability, which can effectively overcome the training difficulties of deep neural network by layer pretraining "layer wise training" [17]. It is based on the sample data through certain training methods to get the deep network structure of multiple levels. e deep network structure obtained by deep learning contains a large number of single elements (neurons). Each neuron is connected with a large number of other neurons. e connection strength (weight) between neurons modifies and determines the function of the network during the learning process. e deep network structure obtained by deep learning conforms to the characteristics of the neural network. e commonly used deep learning models include deep belief network (DBN) [25,26], stacked autoencoders (SAE) [27,28], and convolutional neural network (CNN) [29,30]. e basic structure of CNN is composed of input layer, convolutional layer, pooling layer, full connection layer, and output layer. Generally, several convolution layers and pooling layers are selected.
e alternate setting of the convolutional layer and the pooled layer is adopted. It is that one convolutional layer is connected to a pooled layer, and the pool layer is then connected to a convolutional layer. e characteristics of convolutional neural network are that the original signal is directly used as the input of the network, which avoids the complex feature extraction and image reconstruction process in the traditional recognition algorithm. In the convolution stage, the weight sharing structure is used to reduce the number of weights and the complexity of the network model. At the same time, in subsampling stage, we use the principle of local correlation to subsample the feature map, which can effectively reduce the amount of data processing while retaining the useful structure information [29,30]. e convolutional layer can be defined as follows [31]: where x 0 is the input two-dimensional image, ω 1 and b 1 represent the filters and bias of the convolutional layer, x 1 is the output feature maps of the convolutional layer, * represents the convolutional operator, and g(.) denotes the rectified linear unit (ReLU) activation function. In this paper, the spectral data of each soil sample are one-dimensional vector, which is converted into two-dimensional matrix. e data band of soil spectrum is 226-975 nm, with a total of 749 wavelength points. e one-dimensional spectrum vector of 749 × 1 is converted into a two-dimensional matrix of 28 × 28. e reflectances corresponding to 28 wavelength points are taken from each column in order until 749 reflectances are all ranked in the two-dimensional matrix of 28 × 28, and the rest positions are filled with 0. at   is the input two-dimensional image. Convolution operation is used to transform the spectral image data. e spectral feature information can be extracted more effectively by combining the neighboring information of spectral image. ere are two convolutional layers with six 5 × 5 kernels. e pooling layer is behind the convolution layer and used for reducing the computational complexity [31]. e pooling layer can be defined as where x 2 is the output feature maps of the pooling layer, g(.) denotes the ReLU activation function, and down(.) represents a max-pooling function. In this paper, there are two pooling layers with six 2 × 2 kernels. e fully connected layer is used to extract more deep feature [31]. e fully connected layer can be defined as where ω 3 and b 3 represent the filters and bias of the fully connected layer, x 3 is the output feature maps of the fully connected layer, and g(.) denotes the ReLU activation function. is paper has one fully connected layer. e specific process of CNN is shown in Figure 3. e classifier adopts softmax classifier, and the loss function is mean squared error.

Classification Evaluation Standard.
e classification evaluation standard uses the number of correct prediction classification sample Y p divided by the number of all soil samples Y. e formula is as follows: c � (Y p /Y) * 100%. e closer the c is to 100%, the better the classification effect.

Dividing Calibration Set and Test Set by Kennard-Stone
Algorithm. K-S algorithm was used to divide calibration set and test set of six types of soil. e total number of the calibration set samples ranged from 40 to 150, with an interval of 10, and the rest was test set. e accuracy of classification model in small sample was analyzed. e number of the calibration set samples for each type of soil is shown in Table 3.

Classification Results of Different Types of Soil Based on Convolutional Neural Network.
e spectrum of each calibration set of soil sample was transformed into two-dimensional matrix and then was substituted into CNN network for training. e iterations are 2000. e classification results of the calibration set and the test set are shown in Table 4. When the total number of the calibration set samples was 150-100, the classification accuracy of the calibration set and the -test set was all 100%. e classification results of six types of soil in 90-40 calibration set, including orchards, woodlands, tea plantations, farmlands, bare land, and grasslands, are shown in Table 5.

Journal of Spectroscopy
According to Table 5, the general trend of the test set classification results in the type 1 orchards was that the classification results decreased with the decrease of the label samples. When the total number of the calibration set was 60-90, the classification accuracy was more than 88%; when the total number of the calibration set was 50-40, the classification accuracy dropped rapidly, and the number of the wrong samples in the test set was more than 10. e general trend of the test set classification results in the type 2 woodlands was the same with that of the type 1 orchards. When the total number of the calibration set was 90-70, the classification accuracy was 100%; when the total number of the calibration set was 60-40, there were a small number of samples with wrong judgment in the test set, the number of the wrong samples was 1, 1, and 2, respectively. In the type 3 tea plantations, when the total number of the calibration set was 90-60, the classification accuracy rate was 100%; when the total number of the calibration set was 50-40, the samples with wrong judgment of the test set were 1 and 2, respectively. Because the number of the tea plantations samples was less, the classification accuracy rate was lower when the number of the calibration set was 40. In the type 4 farmlands, when the total number of the calibration set was 90-60, the classification accuracy was 100%; when the total number of the calibration set was 50-40, the accuracy was above 96%. In the type 5 bare land, except for the calibration set of 90 samples, there was a wrong sample. And there was no other sample of misjudgment, that is, the accuracy is 100%. When the total number of the calibration set was 90-40 in the type 6 grasslands, the correct rate is 100%.

Classification Results of Different Soil Types Based on Support Vector Machine.
e spectrum of each calibration set soil sample transformed into two-dimensional matrix was substituted into SVM for training. e kernel function chose the radial basis function (RBF). e classification results of the calibration set and the test set are shown in Table 6. When the total number of samples in the calibration set was 150-100, the classification accuracy of the test set was 100%. Table 7 shows the classification results of six types of soil in the 90-40 samples of the calibration set.
From Table 6 by SVM algorithm, when the total number of calibration set was 150-40, the accuracy of the calibration set decreased with the decrease in the number of the label samples, and all of which were above 90%. Similar to CNN algorithm, when the total number of the calibration set algorithm was 150-100, the classification accuracy of the test set was all 100% by SVM. When the total number of the calibration set was 90-40, the accuracy of classification results in the test set was 98.90%, 98.43%, 98.51%, 98.10%, 91.86%, and 91.34%, respectively. Similar to CNN algorithm, the classification accuracy of more than 60 label samples in the test set was more than 98%. But in the 50-40 label samples, the classification accuracy of the test set dropped sharply, lower than 92%.
According to Table 7, when the total number of the calibration set in the type 1 orchards was 90-60, the correct rate was more than 75%; when the total number of the calibration set was 50 and 40, the wrong samples were more, and the correct rate of the classification was less than 40%. Most of the type 1 were judged as the type 2, indicating that the spectra of the orchards and woodlands were similar. SVM could not predict the category of the orchards correctly. In the type 3 tea plantations, when the total number of the calibration set was 80 and 40, there were 1 and 5 wrong samples, respectively, and the accuracy of the rest was 100%. In the type 5 bare land, except for the calibration set of 40, there was a wrong sample, and other samples were judged right, i.e., the accuracy was 100%. In the type 2 woodlands, the type 4 farmlands, and the type 6 grasslands, when the total number of the calibration set was 90-40, the accuracy was 100%.

Six Types of Soil Classification Results: Dividing the Calibration Set by Random Method.
e number of the soil samples in six types of calibration set had different proportion in their categories by Kennard-Stone algorithm. To further verify the availability of CNN algorithm, the same proportion of soil samples from each type was randomly selected and classified by CNN and SVM algorithm. Table 8 shows that 1/3, 1/4, and 1/5 samples of each soil type were taken as the calibration set samples, respectively. Table 9  According to Table 9, the classification accuracy of the calibration set by CNN was 100%. e 1/3 and 1/4 proportion of the calibration set by SVM had a wrong sample, respectively, and the accuracy in the 1/5 proportion was 100%. In the test set, when the proportion was 1/3 and 1/4, the accuracy of CNN was higher than that of SVM; when the proportion was 1/5, the accuracy of SVM was slightly higher     Figure 4, when the proportion of the calibration set was 1/3 and 1/4, the classification accuracy of six types of soil by CNN was not lower than that by SVM. e classification accuracy of the farmlands, the grasslands, and the woodlands was above 95%, followed by the orchards (88.24%, 84.12%) and the tea plantations (77.78%, 70%). e classification accuracy of the bare land was the worst, which was 66.67% and 60%. When the proportion of the calibration set was 1/5, the classification accuracy by CNN and SVM in the woodlands and the farmlands was the same, with good classification effect (97.1%, 100%). Followed by the grasslands, the classification accuracy was both higher than 85%, and SVM was slightly better than CNN, with 89.36%. e  classification results of the orchards were poor, which was about 60%, and the classification accuracy of the bare land was the lowest, which was lower than 50%. In the classification results of six types of soil, CNN was better than SVM in general. e proportions of 1/3, 1/4 and 1/5 soil samples were taken as the calibration set samples, respectively. Table 10 shows the classification results of different types of soil based on CNN and SVM by randomly dividing the calibration set 10 times.
According to Table 10, the classification results of CNN were better than that of SVM in 1/3 proportion and 1/4 proportion, but it was lower than that of SVM in 1/5 proportion. With the reduction of calibration set samples, the classification accuracy of CNN and SVM test set decreased. Compared with SVM, the classification accuracy of CNN decreased more obviously.

e Feasibility of Land Cover Classification with Small Samples by Convolutional Neural Network.
e essence of CNN is that each convolutional layer contains a certain number of convolution kernels. Compared with the traditional neural network, CNN reduces the number of training weights and computational complexity through weight sharing. CNN is to input the original data directly into the network and conduct network learning in the training data invisibly. It can avoid manual feature extraction and realize automatic classification. CNN is mostly used for the image information classification with a large amount of data, which contains a large number of label samples. But it is seldom used in a small amount of data classification.
In this paper, the spectral data are one-dimensional vector. To be suitable for CNN, it is transformed into twodimensional vector for convolution and other operations, and a better classification effect is obtained. e first reason is that CNN can extract more deep and abstract features of the spectrum, which is conducive to the classification of different types of soil. e second reason is that it takes 2000 iterations to improve the accuracy of the model. SVM is a commonly used classification method, which has a good classification effect in small label samples. In this paper, compared with SVM, CNN not only has a good classification effect in the condition of more training samples but also has a better classification effect in small label samples. However, with the continuous reduction of training samples, SVM has more advantages. erefore, CNN can be applied to the classification of land cover with small samples, but SVM is still better for the training set with too small samples.

e Advantages of the Kennard-Stone Algorithm.
In this paper, different methods are used to divide the samples of the calibration set, and different classification results are obtained. e results by K-S algorithm are good. K-S algorithm is mainly used to select representative samples from the original sample to establish the model. e main idea is to select the spectrum samples with large differences as training samples and uses the samples with relatively close spectrum to predict, so as to avoid the uneven distribution of training samples. However, dividing the calibration set by random method has uncertainty and limited distribution information, so the calibration results by KS classification are better.

e Analysis of the Different Number of Samples in the Calibration Set.
In the analysis of the classification results of various types of soil samples, the woodlands, farmlands, and grasslands, all show good classification effects under the different number of samples in the calibration set. However, the classification accuracy of orchards, tea plantations, and bare lands is not stable. More training samples can have a higher classification accuracy, and less training samples have a decline in classification accuracy. e total samples of forest land, farmland, and grassland are more than 60, while the total samples of orchards, tea plantations, and bare lands are less, with 26, 13, and 13, respectively. CNN cannot train enough calibration set samples, so it cannot get a better classification model, and the test set classification prediction is poor.

Conclusion
Based on the visible near-infrared spectroscopy technology, this paper takes six different types of soil (orchards, woodlands, tea plantations, farmlands, bare land, and grasslands) in Qingdao, China, as examples, and establishes a convolutional neural network classification model. e classification results under the conditions of different number label samples are analyzed, and the classification results with the shallow network SVM are compared. Under the condition that Kennard-Stone algorithm divides the calibration set, the classification results of six different soil types and single six soil types by convolutional neural network are better than those by the support vector machine. e classification accuracy of the test set is above 95%. Under the condition of randomly dividing the calibration set according to the proportion of 1/3 and 1/4, the classification results by convolutional neural network are also better. e classification accuracy of the test set is over 87%. According to the deep learning algorithm, the aim is to explore a new method for rapid, nondestructive, and accurate classification of the land cover. is method has guiding significance for the practical application of soil investigation and mapping.
Data Availability e raw/processed data required to reproduce these findings cannot be shared at this time as the data also form part of an ongoing study.

Conflicts of Interest
e authors report there are no conflicts of interest.