Web software to create thematic maps for precision agriculture

– The objective of this work was to develop and provide a free web application able to generate thematic maps. The initiative aims to incorporate the functionalities of the “Software para Definição de Unidades de Manejo” (SDUM) desktop application, which has proven to be suitable for working with thematic maps and management zones, but that was only available for desktop computers. The developed web application was tested with real data from two agricultural fields located in the state of Paraná, Brazil. Thematic maps of soil and plant characteristics relevant to precision agriculture were created through the following interpolation methods: inverse distance, moving average, and nearest neighbor. The obtained results show that the usage of this web tool allows identifying areas with the same behavior toward soil variables, making it possible for the user to have a better and more accurate vision of the area to be worked on and to identify possible causes of variation in productivity. Because it is installed in a server with on-demand features, the software has a satisfactory performance from a functional point of view and can be accessed from any web environment.


Introduction
Soil variability is the result of complex interactions between the factors and processes involved in its formation, and external agents -such as climatic characteristics, irrigation, and soil and crop management -can influence and change its attributes (Davatgar et al., 2012). Therefore, it is not unusual for the content, distribution, and availability of soil nutrients to vary widely both within and between parcels of land (Corwin & Lesch, 2003), influencing the production and quality of agricultural products. For this reason, the spatial variability of soil chemical and physical attributes is corrected as much as costs and machines allow through the use of precision agriculture technologies (Teixeira et al., 2011).
In precision agriculture, the preparation and analysis of thematic maps allows identifying the spatial distribution of geographical attributes, soil, and plant productivity (Bazzi et al., 2015), which is a necessary step to assist the producer in decision-making (Grego et al., 2014). Based on the analysis of the yield maps that represent the spatial distribution of crop response, it is possible to manage the production of subsequent years by applying a differentiated rate of fertilizers and other agricultural inputs according to local needs (Adamchuk et al., 2011). This allows decreasing environmental impact while increasing productivity and financial returns (Tey & Brindal, 2012).
To generate thematic maps, the georeferenced samples -including soil, plant, and productivitycollected in the study area are used (Rodrigues Jr. et al., 2013). After their collection, the data are entered into a geographic information system (GIS) to generate the map on the topic to be assessed, which could be productivity or soil attributes, for example. In this step, the interpolation of the collected data is performed, and values at unvisited locations are estimated (Kerry et al., 2010). Several techniques are used for interpolation purposes, such as inverse distance to a power (IDP), kriging, nearest neighbor, and moving average, which differ based on how weights are assigned to the different samples (Laslett et al., 1987).
However, choosing that program instead of a tool dedicated for precision agriculture can be a challenge, since most software used to generate thematic maps have not been specifically developed for precision agriculture, but for generic data handling (Whelan & Taylor, 2013). This shows the need for a free, user-friendly software for the execution of all stages of the process of generating management areas in precision agriculture. With this aim, the "Software para Definição de Unidades de Manejo" (SDUM) desktop application, i.e., software for the definition of management units, was developed (Bazzi et al., 2015). This tool allows the creation of thematic maps by known methods of interpolation, generation, and evaluation of management areas. Although the SDUM proved to be a suitable option for working with thematic maps and management areas (Gavioli et al., 2016;Schenatto et al., 2016aSchenatto et al., , 2016b, it is available only for desktop computers and needs to be installed on the user's computer, both unfavorable for the dissemination and use of the software.
The objective of this work was to develop and provide a free web application able to generate thematic maps.

Software development
Reverse engineering was used to develop the online tool for the creation of procedures by software in the context of precision agriculture. This process is considered a form of examining and understanding the existing system (Pfleeger, 2004), aiming to better understand a software, facilitating activities such as expansion, correction, documentation, re-designing, or reprogramming in another programming language (Rugaber & Stirewalt, 2004). Reverse engineering enabled the analysis of the features and technological principles of the SDUM desktop application, allowing to create a new version of the tool at a high level of abstraction, while keeping the functions of thematic maps. It also permitted the addition of new features for a simplified usage in web browsers.
Software modeling assists in the preparation of a quality software, allowing to visualize and control its architecture, to manage risks, and to better understand its requirements (Pressman & Maxim, 2016). For the representation of the features and documentation of the system, the Unified Modeling Language (UML) was adopted. For the layout, the free software Astah Community (Astah, Tokyo, Japan) was used, which allowed to graphically represent the use cases and all features and prerequisites. For software development, free tools were used to facilitate the project, without the need for additional license costs or support. The Pesq. agropec. bras., Brasília, v.55, e00735, 2020 DOI: 10.1590/S1678-3921.pab2020.v55.00735 database management system PostgreSQL (2019) was adopted due to its flexibility and extension for PostGis georeferenced data. The spatial representations shown by satellite images in the software and used in the development environment are made available by the OpenLayers 3 library (OpenLayers 3 Beginner's Guide, 2019), which features online mapping services integration and enables software developers to create geographic applications for the web environment with the capacity to display and manipulate geospatial data. The integrated development environment Eclipse (Eclipse Foundation, Inc., Ontario, Canada), as well as the Apache Tomcat web server (Apache Software Foundation, Wakefield, MA, USA), were also used for developing the new tool. The concept of separation of layers of development (Pfleeger, 2004;Silva, 2010;Sommerville, 2011) was applied, and the Hypertext Markup Language (HTML) was used to structure the web page content. For the presentation layer that consists of style sheets, the Cascading Style Sheets (CSS) language was used to define how the elements of each web page were displayed. In the behavior layer defined by the scripts, the JavaScript programming language was used for data handling and processing. Application layers (user interface), business rules (system feature), and persistence (database in memory) were distinguished to make the system more flexible to changes.
For the communication between the development language and the database, the Hibernate framework (Red Hat, Raleigh, NC, USA) was used, facilitating the mapping of attributes between a traditional database and the object-oriented model of the application. The VRaptor 3 framework (Caleum, Rio de Janeiro, RJ, Brazil) was used to provide a quicker construction of web systems, allowing the implementation of features such as upload/download of files and conversion of data into different formats (XML, JSON, and XHTML, for example) by using the encapsulation HttpServlet Request, Response, Session, as well as the javax.servlet API. Software architecture was built based on the concepts of representational state transfer (REST), since they assist in integration with different systems (Lecheta, 2015), using the REST application programming interface (API).
With the goal of building a distributed and scalable environment, the software architecture was distributed into two layers ( Figure 1). On the server-side, an API for the REST web service (AgDataBox-API) was used for accessing the data persistence layer, managing authentication/authorization methods, and storing of data sent by applications. On the client-side, the application for generating thematic maps (AgDataBox-Maps) established a communication with the server layer (AgDataBox-API) by using the hypertext transfer protocol (HTTP), allowing the communication Pesq. agropec. bras., Brasília, v.55, e00735, 2020 DOI: 10.1590/S1678-3921.pab2020.v55.00735 between the map system and the other systems also integrated into AgDataBox-API, such as Mobile and Sensor, among others. This structure allows users to share their data (fields of study) among different applications, developed by different programmers, in different programming languages, for different purposes.

Operating structure of the AgDataBox-Map software
Because of the need to work with a considerable amount of data, a structure geared towards project management by the user was created ( Figure 2). In the project module, methods to create and edit different projects -each allowing the registration of parcels, sampling grids, and collected samples of various attributes (data on soil and/or plant physical and chemical attributes) -were implemented.
Data regarding the outline and sample data of the area (altitude, pH, phosphorus, and calcium, among others) were also included. For this, three different methods were implemented and made available: delimitation of the parcel and indication of sample points on satellite images, presented to the user with the available drawing tools; import of data from parcels (outline and sample data) previously registered within the AgDataBox-API environment (available in the cloud), with potential use of other software integrated in the API; and import of parcel data (outline and sample data) available in text format files (".txt"), containing two columns of data, representing longitude and latitude, respectively, when defining the area outline, besides an additional column to indicate the points sampled in the parcel.
To allow easy data change, editing interfaces were implemented in the environment, enabling editing operations to position the outline of the parcels and sampling points, as well as changes in the values of the attributes and the exclusion of previously registered points. It is possible to modify the sample grid created from a regular grid, since the points can be dragged to the desired location, erased, or have values attributed to them.

Generation of the thematic maps
The interpolation of data is a necessary procedure for the construction of thematic maps, because it allows estimating the value of attributes in unvisited locations, based on the information obtained from points that were collected (Bazzi et al., 2015). For the generation of the thematic maps, the same interpolation methods used in the SDUM desktop application were where Z corresponds to the value of the Z attribute for the point to be interpolated, Z i is the value of Z in relation to its neighbor i, D i p is the distance between the point to be interpolated (Z) and the sampled data, and p corresponds to the desired power.
Moving average was calculated by: where Z also corresponds to the value of the Z attribute for the point to be interpolated, Z i is the value of Z in relation to its neighbor i, and n is the number of sample elements used for interpolation.
The ordinary kriging functionalities adjust automatically the traditional models used in the literature (spherical, Gaussian, exponential, and Matérn) to the semivariogram, without human interference, using the fitting methods ordinary least squares and weighted least squares. To choose the best fit for each model used, the software adopts statistical cross-validation parameters for the mean error (ME) and the standard deviation of the mean error (SD ME ), as shown in the two following equations, respectively: where n is the number of data; Z(S i ) is the value observed at point S i ; Ẑ(S i ) is the value predicted by ordinary kriging in point S i ; and  Y S i is the prediction of the error associated with the estimate of the value at point S i . The ME and SD ME values are calculated for each set of parameters used to determine the best fit model for the semivariogram. The model is then determined according to the lower value for the interpolation selection index (Bier & Souza, 2017), obtained by: here ISI is the interpolation selection index, abs(ME) is the module value of the average error, SD ME is the standard deviation of the mean error, min j i=1 is the lowest value among the compared of the j interpolators, and max j i=1 is the highest value among the compared interpolators.
In order to perform ordinary kriging interpolation, after the adjustment of the variogram model, the following equation can be used to calculate the estimated value at the point of interest: IDP interpolation assumes the existence of a positive spatial correlation, and the power is used to attenuate the impact of distant points. The IDP is a quick method that generates good results and requires little computational resources (Mazzini & Schettini, 2009). The nearest-neighbor technique is the simplest method of interpolation, since its main characteristic is to ensure that the interpolated value is one of the original values (Franke, 1982). Since it does not generate new values for the Z variable, it is recommended when working with qualitative data, often being used when the data has already been interpolated by another method and if the aim is for the interpolation to keep the original data. For the moving average, values are estimated based on the calculation of the average of the points selected by the user (it is possible to set the number of points in the considered vicinity) or by using a predefined distance between the elements and the location where interpolation application is desired. Kriging, which was detailed in Michelon et al. (2019), is another method, but of regression, applied in geostatistics to approximate or interpolate data based on statistical models that includes spatial autocorrelation, i.e., relationship statistics between measured points.
As the interpolators IDP and moving average must be adjusted according to the user's need, methods were implemented to enable the configuration of the parameters related to the power P (only for the IDP), maximum distance (radius), and/or number of sample elements used in interpolation. It should be noted that Pesq. agropec. bras., Brasília, v.55, e00735, 2020 DOI: 10.1590/S1678-3921.pab2020.v55.00735 it is not necessary to configure these parameters to perform ordinary kriging interpolation. Aside from these settings, the module also allows to change the pixel size of the map (spatial resolution).
To visualize the thematic maps, the user should register a "Classifier Entity" -corresponding to a company, agency, or researcher to serve as a reference for attribute ratings in tabulated form. This function is an alternative that allows the generation of the map in accordance with the interval value proposed by the classifier, facilitating the division of map classes, which is carried out automatically considering the classification of the classifier entity.

Performance assessment
To evaluate the developed tool, performance and accuracy tests were carried out for each feature, aiming at minimizing undesirable results and correcting errors. For the assessment, after the input of parcel delimitation and the inclusion of the sampling data related to soil chemical characteristics and corn (Zea mays L.) productivity, thematic maps of the attributes that used the IDP method were generated. Soil chemical data were classified according to Costa & Oliveira (2001) and accounted for the average corn production in the state during the reviewed year.
The functioning of the application in different viewing environments was tested using the main web browsers available (Mozilla Firefox, Google Chrome, Internet Explorer, and Opera), to evaluate the compatibility of visualization resources. Moreover, to test the accuracy of the thematic maps, the maps generated on the web application were compared with those generated in the SDUM desktop application and in the ArcGis proprietary software (ESRI, Redlands, CA, USA). The maps generated with different configurations of pixel size, radius, exponent, and number of neighbors were compared using the kappa index.

Data used in the case study
For the tests and performance assessment of the software features, experimental data of precision agriculture were used. These data were collected in 2014 in two agricultural fields -field A with 9.9 ha and field B with 23.8 ha -located in the municipality of Serranópolis do Iguaçu, in the state of Paraná, Brazil, in the central geographical coordinates 25°24'28"S and 54°00'17"W and 25°26'49"S and 54°04'59'W, respectively. The soil in the fields is classified as a typical Latossolo Vermelho distroférrico (Santos et al., 2018), i.e., a Typic Haplustox (Soil Survey Staff, 2006), cultivated under a no-tillage system with a succession of soybean [Glycine max (L.) Merr.] and corn crops. The data used for testing refer to soil chemical attributes and corn yield. The sampling grids for data collection are different for the two fields and have a sample density of 4.24 points per hectare (42 samples) for field A and of 3.06 points per hectare (73 samples) for field B.
To determine the location of the sampling points, the Trimble GeoXT GNSS receiver (GeoExplorer, Sunnyvale, CA, USA) was used. At each sampled grid point, eight subsamples were collected within a radius of 3 m of their respective sample point (Wollenhaupt & Wolkowski, 1994) and at a depth of 0.20 m. The collected soil was sent for laboratory analysis, where its chemical attributes were determined. For corn productivity sampling, eight spikes in each sampling point of the grid were manually harvested and separated. After harvesting, screening and manual cleaning were performed. Finally, the grains were weighed, and their mass was corrected to 13% moisture content, according to the instructions for seed analysis (Brasil, 2009).

Results and Discussion
The developed web-based system allows visualizing the geographic outline of the study area and its respective sampling points (Figure 3) through the main screen button "My Projects" (item 1). After the area is selected, the system allows the visualization of the sample data (item 2). The main menu is located at the top of the screen (item 3), where it is possible to register, edit, and delete features, such as: areas and sample attributes, soil types, attribute types, sampling grid, classifier entity, and data interpolation. On the right side of the main menu, are the buttons for changing the language (Portuguese, English, or Spanish) of the interface (item 4), and the username and the logoff option are located to the side (item 5).
Following the organizational architecture of the environment, after the data were registered, data interpolation was executed to generate the thematic maps. For this step, it is advisable to first register -Pesq. agropec. bras., Brasília, v.55, e00735, 2020 DOI: 10.1590/S1678-3921.pab2020.v55.00735 via "Classifier Entity" in the main menu -an entity, organ, or researcher that presents the classification for the attributes to be used in generating the maps in a tabulated manner; this allows registering intervals and colors for each classification level. However, it is also possible to generate thematic maps without the need of a classifier entity; in this case, a fixed number of ranges is preferable, considering the lower and upper limits of the attributes of the map to be generated.
The environment enables the creation of thematic maps through the button "Create Thematic Maps" available from the main menu, and the users have the possibility of changing settings according to their need, considering parameters related to the type of interpolator (IDP, moving average, nearest neighbor, or kriging), to the pixel size of the map (spatial resolution), to the values of the exponent (IDP only), to the number of neighbors, and to the radius. The Pesq. agropec. bras., Brasília, v.55, e00735, 2020 DOI: 10.1590/S1678-3921.pab2020.v55.00735 generated map can be viewed through the main screen button "My Thematic Maps" (Figure 4).
The influence of the parameters used in the interpolation process can be observed on the thematic maps for organic matter, collected in 2015, in field A ( Figure 5), and for phosphorus, collected in 2015, in field B ( Figure 6). The maps were generated by the inverse distance interpolation method raised to the exponents of 1 (ID, inverse of distance) and 2 (IDS, inverse of distance squared), with different configurations to compare the impact of the following parameters: power, which allows giving higher priority or greater importance to the closest neighbors; pixel size, which determines the distance between the center of a polygon and the nearest neighbor(s); radius, a parameter that defines the distance for the selection of samples for the interpolation of a pixel; and number of neighbors to be considered for each pixel interpolation.
Visually, there was an increase in the level of detail of the map with 5x5-m pixel size generated by IDS (Figures 5 and 6), with much more defined curves than those of the map with 20x20 m pixels. On the 10x10-m pixel map, interpolation extends beyond the boundaries of the area outline. Regarding power, the higher the value, the more important the nearby points become, as is evident from the maps (Figures 5 and 6 C and D). The parameter for the number of neighbors ensures that at least one sampling point is selected for the interpolation of each pixel when the radius is equal to zero. It can be seen that when the number of   neighbors was equal to zero and the radius equal to ten, the map did not represent efficiently the attribute phosphorus variability, as it did when the number of neighbors and the radius received a value equal to 10 ( Figure 6 D and C). For comparison, the maps generated in the SDUM desktop application, the AgDataBox-Map, and ArcGIS for the phosphorus attribute, collected in 2015, are shown ( Figure 8). The interval was chosen according to the values recommended for the soil of the experimental area, a typical Latossolo Vermelho distroférrico (Costa & Oliveira, 2001), i.e., a Typic Haplustox (Soil Survey Staff, 2006). The following were used: IDS interpolator, number of neighbors equal to 10, radius equal to 0, and pixel size of 5x5 m.
Changes were not detected in the platform when accessed in the different browsers tested -Mozilla Firefox, Google Chrome, Internet Explorer, and Opera.  Pesq. agropec. bras., Brasília, v.55, e00735, 2020 DOI: 10.1590/S1678-3921.pab2020.v55.00735 Conclusions 1. The AgDataBox-Map software, developed to create thematic maps for precision agriculture, proved to be a good free software option, since the generated maps are similar to those generated by the software for definition of management units (SDUM) desktop application and the ArcGIS proprietary software.
2. The use of technologies to build the software are shown to be satisfactory from a technical (computational) point of view and rendered the construction of a tool with features similar to those of geographic information systems.