Method, device, equipment, medium and product for determining regional farmland nitrogen and phosphorus loss amount
By dividing farmland into grid cells and using the D8 algorithm and loss rate prediction model to calculate nitrogen and phosphorus loss, the calculation deviation and accuracy problems from field scale to regional scale are solved, and the accurate extrapolation and distribution display of nitrogen and phosphorus loss are realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- AGRO ENVIRONMENTAL PROTECTION INST OF MIN OF AGRI
- Filing Date
- 2026-01-28
- Publication Date
- 2026-06-19
AI Technical Summary
In the calculation of nitrogen and phosphorus loss in farmland, existing technologies suffer from high costs and long cycles for field-scale monitoring, and deviations are easily caused when extrapolating measured data to the regional scale. The accuracy and universality of regional scale models are poor, and it is difficult to obtain parameters for mechanistic models, leading to the accumulation of errors and affecting the accuracy of calculations.
The farmland in the study area was divided into grid cells. The D8 algorithm was used to determine the direction of nitrogen and phosphorus loss. The weight of flow tendency was determined based on the elevation difference. Combined with the data of nitrogen and phosphorus loss influencing factors and the loss rate prediction model, the nitrogen and phosphorus loss of each grid cell was calculated, and the loss distribution map was drawn.
It enables accurate calculations of nitrogen and phosphorus loss from small to large scales even with limited field monitoring data, solving the problems of estimation bias and imprecise calculation of loss, and improving the accuracy and universality of loss calculation.
Smart Images

Figure CN121601070B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of agricultural environmental science, and in particular to a method, apparatus, equipment, medium, and product for determining nitrogen and phosphorus loss from regional farmland. Background Technology
[0002] Currently, the calculation of nitrogen and phosphorus loss from farmland covers two scales: field and region. At the field scale, representative fields are typically selected by comprehensively considering factors such as climate, topography, and planting patterns. Runoff collection ponds are set up to measure runoff volume, collect surface runoff from rainfall or irrigation, analyze the nitrogen and phosphorus content, and then calculate the loss based on runoff volume and nitrogen and phosphorus concentration. The nitrogen and phosphorus loss rate is determined by the ratio of the total loss from multiple runoff events to the total nitrogen and phosphorus fertilizer application in the field. At the regional scale, model estimation (empirical model, mechanistic model) is used to spatially extrapolate the loss volume by combining data on farmland nitrogen and phosphorus input, natural geography, soil, and rainfall.
[0003] However, existing methods have many problems: (1) Field-scale monitoring is costly and time-consuming. When the measured data is pushed to a larger scale, due to the heterogeneity of the plots, simply extrapolating the data of the measured plots to other plots and summing them can easily cause the estimation of nitrogen and phosphorus loss to be biased; (2) Regional-scale empirical models do not fully reflect the mechanism and have poor accuracy and universality; (3) Although the mechanism model can reflect the mechanism, the model is complex and requires many parameters. The difficulty in obtaining parameters will cause the model to fail to run due to missing parameters. Moreover, the more parameters there are, the more parameter data errors accumulate, which will directly affect the accuracy of the nitrogen and phosphorus loss calculation results and bring challenges to the implementation of precise prevention and control measures.
[0004] Therefore, a method is needed to solve the problem of difficulty in obtaining parameters, as well as the problem of inaccurate calculations caused by too many model parameters and errors in parameter data when extrapolating nitrogen and phosphorus loss calculations from small scales to large scales. Summary of the Invention
[0005] The purpose of this application is to provide a method, apparatus, equipment, medium, and product for determining regional nitrogen and phosphorus loss in farmland. The parameters are easy to obtain and can solve the problem of inaccurate and imprecise calculation results when the calculation of regional nitrogen and phosphorus loss is extrapolated from a small-scale field to a large-scale regional scale when there is limited monitoring data on nitrogen and phosphorus loss in fields.
[0006] To achieve the above objectives, this application provides the following solution:
[0007] Firstly, this application provides a method for determining nitrogen and phosphorus loss from regional farmland, including:
[0008] Data on nitrogen and phosphorus input and nitrogen and phosphorus loss influencing factors were obtained from farmland in the study area.
[0009] The farmland in the study area was divided into grid units;
[0010] Based on the grid cells, the D8 algorithm is used to determine the direction of nitrogen and phosphorus loss in each grid cell of farmland in the study area according to the elevation difference;
[0011] The flow tendency weight is determined based on the direction of nitrogen and phosphorus loss from the grid cells and the elevation difference between the grid cells and the flow direction.
[0012] The nitrogen and phosphorus loss rate of each grid cell is determined using a loss rate prediction model based on the nitrogen and phosphorus loss influencing factor data.
[0013] The nitrogen and phosphorus inflow of the upstream grid cells surrounding the current grid cell is determined based on the flow tendency weight.
[0014] The actual nitrogen and phosphorus input of each grid cell is determined based on the nitrogen and phosphorus inflow of the upstream grid cells surrounding each grid cell and the nitrogen and phosphorus element input of each grid cell.
[0015] The amount of nitrogen and phosphorus loss for each grid cell is determined based on the actual nitrogen and phosphorus input and nitrogen and phosphorus loss rate.
[0016] The amount of nitrogen and phosphorus loss from farmland in the study area was determined based on the amount of nitrogen and phosphorus loss in each grid cell.
[0017] In one embodiment, before determining the direction of nitrogen and phosphorus loss in each grid cell of farmland in the study area based on the elevation difference using the D8 algorithm according to the grid cells, the method further includes:
[0018] The input amounts of nitrogen and phosphorus elements and the data on nitrogen and phosphorus loss influencing factors are processed by text vectorization and rasterization.
[0019] In one embodiment, the nitrogen and phosphorus loss direction of each grid cell is determined based on the elevation difference using the D8 algorithm, specifically including:
[0020] The elevation difference between each grid cell and its adjacent grid cells is calculated based on the D8 algorithm.
[0021] The direction of nitrogen and phosphorus loss in each grid cell is determined based on the elevation difference.
[0022] In one embodiment, the flow tendency weight is determined based on the nitrogen and phosphorus loss direction of the grid cells and the elevation difference between the grid cells and the flow direction, specifically including:
[0023] A grid cell whose flow direction is determined by the nitrogen and phosphorus loss direction of the grid cell;
[0024] Determine the elevation difference between grid cells and flow direction grid cells based on grid cells and flow direction grid cells;
[0025] The flow tendency weight of nitrogen and phosphorus loss from a grid cell to surrounding grid cells is determined based on the proportion of the elevation difference to the sum of the elevation differences between the grid cell and all grid cells to which the flow is to be directed.
[0026] In one embodiment, the nitrogen and phosphorus loss rate of each grid cell is determined using a loss rate prediction model based on the nitrogen and phosphorus loss influencing factor data, specifically including:
[0027] The nitrogen and phosphorus loss impact factor data of each grid cell are normalized to obtain the normalized impact factor;
[0028] The normalized loss impact factor data is input into the loss rate prediction model for prediction, and the nitrogen and phosphorus loss rate of each grid cell is obtained. The loss rate prediction model is obtained by training the random forest model with the actual loss impact factor data as input and the measured nitrogen and phosphorus loss rate as output.
[0029] In one embodiment, after determining the nitrogen and phosphorus loss of farmland in the study area based on the nitrogen and phosphorus loss of each grid cell, the method further includes:
[0030] The direction of nitrogen and phosphorus flow in each grid cell is determined based on the elevation difference, and the slope value in each direction of each grid cell is calculated.
[0031] Select the direction with the largest slope value of the grid cell as the main flow direction of the grid cell;
[0032] The main nitrogen and phosphorus loss directions of farmland in the study area were determined based on the main loss direction of the grid cells;
[0033] A distribution map of nitrogen and phosphorus loss in farmland within the study area was drawn based on the main loss direction of nitrogen and phosphorus in the study area.
[0034] Secondly, this application provides a device for determining nitrogen and phosphorus loss from regional farmland, comprising:
[0035] The acquisition module is used to acquire data on nitrogen and phosphorus input and nitrogen and phosphorus loss influencing factors in farmland within the study area.
[0036] The splitting module is used to split the farmland in the study area into grid cells;
[0037] The loss direction determination module is used to determine the nitrogen and phosphorus loss direction of each grid cell in the farmland of the study area based on the elevation difference using the D8 algorithm.
[0038] The flow tendency weight determination module is used to determine the flow tendency weight based on the nitrogen and phosphorus loss direction of the grid cells and the elevation difference between the grid cells and the flow direction.
[0039] The prediction module is used to determine the nitrogen and phosphorus loss rate of each grid cell based on the nitrogen and phosphorus loss influencing factor data and the loss rate prediction model.
[0040] The module for determining the inflow of nitrogen and phosphorus into the upstream grid cells surrounding the current grid cell is used to determine the inflow of nitrogen and phosphorus into the upstream grid cells surrounding the current grid cell based on the flow tendency weight.
[0041] The actual nitrogen and phosphorus input determination module is used to determine the actual nitrogen and phosphorus input of each grid cell based on the nitrogen and phosphorus inflow of the upstream grid cells surrounding each grid cell and the nitrogen and phosphorus element input of each grid cell.
[0042] The module for determining nitrogen and phosphorus loss in each grid cell is used to determine the amount of nitrogen and phosphorus loss in each grid cell based on the actual nitrogen and phosphorus input and nitrogen and phosphorus loss rate.
[0043] The module for determining nitrogen and phosphorus loss in farmland within the study area is used to determine the nitrogen and phosphorus loss in farmland within the study area based on the nitrogen and phosphorus loss in each grid cell.
[0044] Thirdly, this application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method for determining nitrogen and phosphorus loss in regional farmland.
[0045] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for determining nitrogen and phosphorus loss in regional farmland.
[0046] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the method for determining nitrogen and phosphorus loss in regional farmland.
[0047] According to the specific embodiments provided in this application, the following technical effects are disclosed:
[0048] This application provides a method, apparatus, equipment, medium, and product for determining nitrogen and phosphorus loss in regional farmland. First, the farmland in the study area is divided into grid cells. The direction of nitrogen and phosphorus loss and the main loss direction for each grid cell are determined. The flow tendency weight is determined based on the loss direction of the grid cell and the elevation difference between the grid cells and the cells with the flow direction. The input amounts of nitrogen and phosphorus elements, as well as readily available, large-volume loss influencing factors, are directly acquired. Then, a loss rate prediction model is used to predict the loss rate. The nitrogen and phosphorus loss is calculated based on the actual nitrogen and phosphorus input amounts and loss rates of the grid cells. This addresses the problems of limited actual nitrogen and phosphorus loss monitoring data for current fields, leading to biased loss estimates when directly extrapolating from the field scale to a larger scale; insufficient mechanistic reflection and poor accuracy and universality when using empirical models to extrapolate to a large regional scale; and poor availability of parameter data and cumulative errors affecting the accuracy of loss calculation results when using mechanistic models. This method achieves accurate loss calculation. Ultimately, it solves the problem of inaccurate and imprecise calculation results when extrapolating nitrogen and phosphorus loss from a small scale to a large scale under limited field nitrogen and phosphorus loss monitoring data. Attached Figure Description
[0049] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0050] Figure 1 Flowchart for calculating nitrogen loss direction;
[0051] Figure 2 This is a diagram showing the main nitrogen loss direction;
[0052] Figure 3 This is a map showing the distribution of nitrogen loss.
[0053] Figure 4 This is a diagram showing the main direction of phosphorus loss.
[0054] Figure 5 This is a distribution map of phosphorus loss.
[0055] Figure 6 Flowchart for determining nitrogen and phosphorus loss from regional farmland;
[0056] Figure 7 For technology roadmap;
[0057] Figure 8 A schematic diagram of the functional modules of a device for determining nitrogen and phosphorus loss in regional farmland;
[0058] Figure 9This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0059] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0060] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0061] In one exemplary embodiment, such as Figure 6 As shown, a method for determining nitrogen and phosphorus loss in regional farmland is provided. This method is executed by computer equipment, specifically by a terminal or server alone, or by both a terminal and a server. In this embodiment, the method includes the following steps.
[0062] Step 601: Obtain data on nitrogen and phosphorus input and nitrogen and phosphorus loss influencing factors in farmland of the study area.
[0063] Step 602: Divide the farmland in the study area into grid cells.
[0064] Step 603: Based on the grid cells, use the D8 algorithm to determine the nitrogen and phosphorus loss direction of each grid cell in the farmland of the study area according to the elevation difference.
[0065] Step 604: Determine the flow tendency weight based on the nitrogen and phosphorus loss direction of the grid cells and the elevation difference between the grid cells and the flow direction.
[0066] Step 605: Determine the nitrogen and phosphorus loss rate of each grid cell using the loss rate prediction model based on the nitrogen and phosphorus loss influencing factor data.
[0067] Step 606: Determine the nitrogen and phosphorus inflow of the upstream grid cells surrounding the current grid cell based on the flow tendency weight.
[0068] Step 607: Determine the actual nitrogen and phosphorus input of each grid cell based on the nitrogen and phosphorus inflow of the upstream grid cells surrounding each grid cell and the nitrogen and phosphorus element input of each grid cell.
[0069] Step 608: Determine the amount of nitrogen and phosphorus loss for each grid cell based on the actual nitrogen and phosphorus input and nitrogen and phosphorus loss rate.
[0070] Step 609: Determine the nitrogen and phosphorus loss of farmland in the study area based on the nitrogen and phosphorus loss of each grid cell.
[0071] The above steps first involve dividing the farmland in the study area into grid cells, determining the nitrogen and phosphorus loss direction and main loss direction for each grid cell, and determining the flow tendency weight based on the loss direction of the grid cell and the elevation difference with the grid cell in the flow direction. Then, the input element amounts and readily available, high-volume nitrogen and phosphorus loss influencing factors are directly acquired. Next, a loss rate prediction model is used to predict the loss rate, and the nitrogen and phosphorus loss is calculated based on the actual nitrogen and phosphorus input amounts and loss rates of the grid cells. This approach addresses the limitations of current field nitrogen and phosphorus loss monitoring data, which leads to biased loss estimates when directly extrapolating from the field scale to a larger scale; or the insufficient reflection of mechanisms and poor accuracy and universality when using empirical models to extrapolate to a large regional scale; and the poor availability of parameter data and cumulative errors affecting the accuracy of loss calculation results when using mechanistic models. This approach achieves accurate loss calculation. Ultimately, it solves the problem of inaccurate and imprecise nitrogen and phosphorus loss calculations when extrapolating from a small scale to a large scale under limited field nitrogen and phosphorus loss monitoring data.
[0072] In an exemplary embodiment, before determining the direction of nitrogen and phosphorus loss in each grid cell of farmland in the study area based on the elevation difference using the D8 algorithm according to the grid cells, the method further includes: performing text vectorization and rasterization processing on the nitrogen and phosphorus element inputs and the nitrogen and phosphorus loss influencing factor data.
[0073] In an exemplary embodiment, the nitrogen and phosphorus loss direction of each grid cell is determined based on the elevation difference using the D8 algorithm, specifically including: calculating the elevation difference between each grid cell and its adjacent grid cells based on the D8 algorithm; and determining the nitrogen and phosphorus loss direction of each grid cell based on the elevation difference.
[0074] In an exemplary embodiment, determining the flow tendency weight based on the nitrogen and phosphorus loss direction of the grid cell and the elevation difference with the grid cell in the flow direction specifically includes: determining the grid cell in the flow direction based on the nitrogen and phosphorus loss direction of the grid cell; determining the elevation difference between the grid cell and the grid cell in the flow direction based on the grid cell and the grid cell in the flow direction; and determining the flow tendency weight of the grid cell for nitrogen and phosphorus loss to the surrounding grid cells according to the proportion of the elevation difference to the sum of the elevation differences between the grid cell and all grid cells in the flow direction.
[0075] In an exemplary embodiment, the nitrogen and phosphorus loss rate of each grid cell is determined using a loss rate prediction model based on the nitrogen and phosphorus loss influencing factor data. Specifically, this includes: normalizing the nitrogen and phosphorus loss influencing factor data of each grid cell to obtain normalized loss influencing factor data; inputting the normalized loss influencing factor data into the loss rate prediction model for prediction to obtain the nitrogen and phosphorus loss rate of each grid cell; the loss rate prediction model is obtained by training a random forest model with actual loss influencing factor data as input and measured nitrogen and phosphorus loss rate as output.
[0076] In an exemplary embodiment, after determining the nitrogen and phosphorus loss of farmland in the study area based on the nitrogen and phosphorus loss of each grid cell, the method further includes: determining the nitrogen and phosphorus flow direction of each grid cell based on the elevation difference, and calculating the slope value of each grid cell in each direction; selecting the direction with the largest slope value of the grid cell as the main loss direction of the grid cell; determining the main loss direction of nitrogen and phosphorus in the study area based on the main loss direction of the grid cell; and drawing a distribution map of nitrogen and phosphorus loss of farmland in the study area based on the main loss direction of nitrogen and phosphorus in the study area.
[0077] This application, based on an environmental database, rasterizes data on nitrogen and phosphorus inputs and environmental factors influencing nitrogen and phosphorus loss from farmland. Using the D8 algorithm, it determines the direction and main direction of nitrogen and phosphorus loss for each raster cell in the study area based on the elevation difference between the raster cell and its surrounding cells. It then determines the flow tendency weight based on the loss direction of the raster cell and the elevation difference with the raster cells in the flow direction. A loss rate prediction model is constructed based on a random forest model, and the loss influencing factor data is input into the model to obtain the loss rate for each raster. Based on the flow tendency weight, the nitrogen and phosphorus inflow from upstream raster cells surrounding the current raster cell is determined. The local nitrogen and phosphorus input of each raster cell is summed with the inflow from its upstream raster cells to obtain the actual nitrogen and phosphorus input for each raster cell. Finally, based on the actual nitrogen and phosphorus input and loss rate of the raster cells, the nitrogen and phosphorus loss amount for each raster cell is determined, resulting in a nitrogen and phosphorus loss distribution map for the region. This comprehensive analysis and presentation of regional nitrogen and phosphorus loss from two dimensions—loss amount and main loss direction—provides technical support for regional nitrogen and phosphorus loss risk classification and zoning management.
[0078] In practical applications, such as Figure 7 As shown, this application mainly includes five steps: environmental database construction, data preprocessing, churn direction and main churn direction determination, churn rate prediction model construction, and churn calculation.
[0079] Environment database construction:
[0080] Environmental data for the study area were collected to construct an environmental database. The environmental data included three categories: nitrogen and phosphorus loss rate, nitrogen and phosphorus input, and influencing factors of nitrogen and phosphorus loss. Data collection methods included, but were not limited to, reviewing literature, books, experimental reports, and project summary reports. Influencing factors included, but were not limited to, soil texture, daily rainfall, crop type, vegetation cover, and elevation (DEM). Soil texture was characterized by the content of sand, clay, and silt in the soil.
[0081] The calculation method for nitrogen loss is the same as that for phosphorus loss. The following method uses the calculation of nitrogen loss as an example:
[0082] Data preprocessing:
[0083] 1. Use a unified spatial reference system and determine the grid size according to the size of the study area; spatial reference systems include two types: geographic coordinate systems and planar coordinate systems, both of which must be unified.
[0084] 2. The text content in the impact factor is processed into text vectors; text vectorization methods include, but are not limited to, bag-of-words model methods, word embedding methods, etc.
[0085] 3. All data in the environmental database, except for nitrogen and phosphorus loss rates, are processed into raster layers with uniform raster sizes, each raster cell being a raster unit; processing methods include, but are not limited to, using tools such as ArcGIS, Mapgis, and Python; the raster layer covers the entire area of the study region.
[0086] Determining the direction of data loss and the primary direction of data loss:
[0087] 1. Based on the D8 algorithm principle, calculate the elevation difference between each grid cell i and its adjacent grid cell j. (Elevation value of i minus elevation value of j); when i and j are in a horizontal or vertical direction, the grid distance is 1; when they are in a diagonal direction, the grid distance is... .
[0088] 2. If the elevation difference If the difference is greater than or equal to 0, it is considered a positive height difference. If the flow is j, it does not flow to i, and the flow is i to j. This determines the direction of the flow.
[0089] 3. Calculate the slope values L in the eight directions of grid cell i. ij The formula is as follows:
[0090] L ij = / Grid distance.
[0091] 4.8 slope values L ijThe largest direction represents the main nitrogen loss direction of grid cell i, and it is marked as 1. All other directions are marked as 0. The main nitrogen loss direction of each grid cell is calculated in the same way to obtain the main nitrogen loss direction of the study area.
[0092] Churn rate prediction model construction:
[0093] 1. Extract the loss influencing factor data from the raster at the corresponding location of the nitrogen loss rate data point distribution map based on the latitude and longitude of the points; the extraction methods include, but are not limited to, using tools such as ArcGIS, Mapgis, and Python.
[0094] 2. Normalize the extracted churn impact factor data so that all values are between [0,1] to obtain normalized churn impact factor data; normalization methods include, but are not limited to, Min-Max normalization, Max absolute value normalization, Sigmoid function normalization, etc.
[0095] 3. Using normalized churn impact factor data as independent variables and nitrogen churn rate as dependent variable, a random forest is trained to obtain a churn rate prediction model based on the random forest model.
[0096] 4. Extract the center points of all raster cells, further extract the leaching influencing factor data for each center point, perform normalization processing, and input the data into the leaching rate prediction model to obtain the nitrogen leaching rate of all raster cells. When there is collected measured nitrogen leaching rate data within a raster cell, the nitrogen leaching rate of that raster cell is not calculated using the nitrogen leaching rate predicted by the model; to ensure accuracy, the collected measured nitrogen leaching rate of that raster cell is used for nitrogen leaching calculation. When there are multiple collected measured nitrogen leaching rate data within a raster cell, the average of the multiple measured nitrogen leaching rates is calculated as the nitrogen leaching rate of that raster cell, and the nitrogen leaching rate of that raster cell is not calculated using the nitrogen leaching rate predicted by the model. The leaching rate prediction model is established using the measured leaching rate (Y) and the corresponding leaching rate influencing factor (X). Measuring the loss rate is time-consuming and labor-intensive. It requires collecting runoff from different crop plots, planting patterns, and altitudes over a growing season, using methods such as digging runoff ponds, and analyzing the nitrogen and phosphorus content in the runoff. The loss is calculated by dividing the loss by the fertilizer input. Alternatively, one can select typical planting patterns and measure the loss rate. Then, by modeling the relationship between the measured loss rate (Y) and its corresponding value (X), easily accessible data on loss-influencing factors (elevation, soil texture, vegetation cover, crop type, rainfall, etc.) can be used to predict the loss rate using a loss prediction model.
[0097] Churn Calculation:
[0098] 1. When the elevation difference ≥0 is considered a positive elevation difference, meaning the elevation of raster cell j is less than or equal to the elevation of raster cell i, and nitrogen in raster cell j does not flow to raster cell i; when the elevation difference is less than or equal to the elevation of raster cell i, nitrogen in raster cell j does not flow to raster cell i. <0 is considered a negative elevation difference, meaning the elevation of grid cell j is greater than the elevation of grid cell i. The nitrogen in grid cell j will flow to grid cell i, and grid cell j will be further marked as the upstream grid of grid cell i.
[0099] 2. When When <0, calculate the flow tendency weight w from grid cell j to grid cell i. ji The formula is as follows:
[0100] .
[0101] in The elevation difference between grid cell j and grid cell i is (the elevation value of j minus the elevation value of i); k is all grid cells adjacent to j that have a lower elevation than grid cell j, i.e., i is one of the grid cells in k.
[0102] 3. Calculate the total nitrogen inflow into the upstream grid. The formula is as follows:
[0103] .
[0104] in This indicates the current grid. This represents all upstream graticles of this graticle i. This indicates one of the upstream grid cells of this grid. This indicates that j belongs to the upstream grid of this grid i. one; This represents the total nitrogen inflow of the upstream grid cell of grid i. The actual nitrogen input to upstream grid cell j is (local input + total upstream inflow to j). The nitrogen loss rate of upstream grid cell j; w ji The flow tendency weight from grid cell j to grid cell i; elevation difference. When the value is ≥0, the nitrogen inflow to the upstream grid is 0.
[0105] 4. Calculate the actual nitrogen input of grid cell i. The formula is as follows:
[0106] .
[0107] in This represents the actual nitrogen input amount of grid cell i. This represents the total upstream nitrogen inflow of grid i. This represents the local nitrogen input of grid cell i.
[0108] 5. Calculate the nitrogen loss of grid cell i. This allows for the acquisition of a nitrogen loss distribution map of the study area, supporting the regional nitrogen loss risk classification and zoning, as shown in the following formula:
[0109] .
[0110] in This represents the amount of nitrogen loss in grid cell i. This represents the actual nitrogen input amount of grid cell i. This represents the nitrogen loss rate of grid cell i.
[0111] This application divides the study area into grid cells to determine the direction of nitrogen and phosphorus loss. Using various readily available and abundant environmental factors influencing loss as independent variables, a loss rate prediction model is constructed to calculate the nitrogen and phosphorus loss rate. The actual nitrogen and phosphorus input and loss rate of each grid cell are used to calculate the total nitrogen and phosphorus loss. This addresses the problems of limited actual nitrogen and phosphorus loss monitoring data in current fields, leading to biased loss estimates when directly extrapolating from the field scale to a larger scale; insufficient mechanistic reflection and poor accuracy and generalization when using empirical models to extrapolate to a large regional scale; and poor parameter data availability and cumulative errors affecting the accuracy of loss calculation results when using mechanistic models. This approach achieves accurate loss calculation. Ultimately, it solves the problem of inaccurate and imprecise nitrogen and phosphorus loss calculations when extrapolating from a small scale to a large scale under limited field nitrogen and phosphorus loss monitoring data. Compared with existing methods, this application effectively overcomes the limitation of traditional methods that rely on limited point data to achieve full spatial coverage, and improves the accuracy and generalization ability of loss rate prediction through machine learning.
[0112] In another exemplary embodiment, a specific process for calculating nitrogen loss is provided in the method for determining nitrogen and phosphorus loss in regional farmland.
[0113] 1. Environment database construction:
[0114] By consulting books and literature, we collected information on measured nitrogen loss rate, nitrogen input, and environmental factors affecting nitrogen loss, such as soil texture, daily rainfall, crop type, vegetation cover, and elevation (DEM), in study area A to construct an environmental database. Nitrogen input was calculated by collecting fertilizer input data. Soil texture was characterized by the content of sand, clay, and silt in the soil.
[0115] 2. Data preprocessing:
[0116] (1) Based on the area of the study area A and the calculation requirements, the grid size is determined to be 100m×100m.
[0117] (2) The two types of text data, soil texture and crop type, are vectorized using the bag-of-words model.
[0118] (3) Using ArcGIS software, the data layers such as nitrogen input, soil texture, daily rainfall, crop type, vegetation cover, and DEM were rasterized into a total of 36 raster units.
[0119] 3. Determining the direction of data loss and the main direction of data loss:
[0120] (1) Based on the D8 principle, the elevation difference in eight directions of each grid cell was calculated. The calculation process and results are shown in [link to calculation]. Figure 1 .
[0121] (2) If the elevation difference between the grid and the surrounding grid (grid elevation - surrounding grid elevation) is ≥0, it is considered a positive elevation difference. Nitrogen from the surrounding grid does not flow to the grid, while nitrogen from the grid flows to the surrounding grid. This determines the direction of loss.
[0122] (3) Calculate the slope values in 8 directions for each grid cell. The slope is equal to the elevation difference divided by the grid distance. When a grid cell is horizontal or vertical to its surrounding grid cells, the grid distance is 1; when they are diagonally opposite, the grid distance is... The grid cells in the direction of the maximum slope are marked with 1, indicating the main flow direction; the remaining grid cells are marked with 0. This yields the nitrogen main flow direction map. (See attached image.) Figure 2 .For example, Figure 1 The slope matrix corresponding to the elevation difference matrix of the eight directions surrounding the central grid 9 (i.e., the grid with an elevation value of 115) should be: ((1, -18 / ), (2, -5 / 1), (3, 5 / ), (4, -16 / 1), (9, 0 / 1), (5, 8 / 1), (6, -10 / ), (7, 2 / 1), (8, 10 / The calculation results are ((1, -12.73), (2, -5), (3, 3.54), (4, -16), (9, 0), (5, 8), (6, -7.07), (7, 2), (8, 7.07)). Comparing the slope values in the eight directions, it is found that the slope value of grid 5 (the grid with an elevation value of 107) is 8, which is a positive elevation difference and the largest elevation difference value. Therefore, the direction of grid 5 is the main flow direction of this grid (the grid with an elevation value of 115), that is, nitrogen mainly flows from the grid with an elevation value of 115 to the grid with an elevation value of 107. Figure 2 The grid with an elevation of 107 is marked as 1. The main flow direction is found for other grids using the same method, ultimately obtaining the main flow direction for the region.
[0123] 4. Churn Rate Prediction Model Construction:
[0124] (1) Using ArcGIS software, nitrogen loss influencing factor data for corresponding locations were extracted based on the latitude and longitude of the nitrogen loss rate data in the environmental database, totaling 490 data points.
[0125] (2) The extracted nitrogen loss influencing factor data were normalized using the Min-Max normalization method to obtain five types of normalized loss influencing factor data: soil texture, daily rainfall, crop type, vegetation cover, and DEM.
[0126] (3) Using the data on nitrogen loss factors obtained in the previous step as independent variables and all collected measured nitrogen loss rates as dependent variables, the training set and test set are divided in a 6:4 ratio and input into the random forest model for model training. When the model's determination coefficient R 2 When the value is greater than 0.7, the training is complete, and the churn rate prediction model is obtained.
[0127] (4) The center points of 36 raster cells were extracted using ArcGIS software. Soil texture, daily rainfall, crop type, vegetation cover and DEM data layer data were further extracted, normalized, and input into the loss rate prediction model to obtain the nitrogen loss rate of 36 raster cells.
[0128] (5) Among the 36 grid cells, 19 grid cells contain the collected measured nitrogen loss data (6 of which contain multiple measured nitrogen loss rate data, so the mean of multiple measured nitrogen loss rates needs to be calculated). The collected measured nitrogen loss rate data replaces the nitrogen loss rate data predicted by the model to obtain the nitrogen loss rate distribution map.
[0129] 5. Loss Calculation:
[0130] (1) Based on the elevation difference calculated in step 3, the grid cells are divided into two categories: elevation difference < 0 and elevation difference ≥ 0. When the elevation difference < 0, the flow tendency weight of upstream grid to grid is calculated. Weight × upstream grid nitrogen loss = nitrogen inflow to grid.
[0131] (2) The nitrogen inflow of the upstream grid + the local nitrogen input of the grid = the actual nitrogen input of the grid. Calculate the actual nitrogen input of each grid cell separately.
[0132] (3) Based on the calculated actual nitrogen input and the nitrogen loss rate distribution map, calculate the nitrogen loss of all grid cells and obtain the nitrogen loss rate distribution map, see Figure 3 .
[0133] (4) Combining the nitrogen main loss direction map and the nitrogen loss distribution map, it was determined that nitrogen in the study area A mainly flows from the upper left region to the lower right region.
[0134] In another exemplary embodiment, a specific process for calculating phosphorus loss is provided in the method for determining nitrogen and phosphorus loss in regional farmland.
[0135] 1. Environment database construction:
[0136] By consulting books and literature, we collected information on measured phosphorus loss rate, phosphorus input, and environmental factors affecting phosphorus loss in the study area L. These environmental factors included soil texture, daily rainfall, crop type, vegetation cover, and elevation (DEM), and an environmental database was constructed. Phosphorus input was calculated by collecting fertilizer input data. Soil texture was characterized by the content of sand, clay, and silt in the soil.
[0137] 2. Data preprocessing:
[0138] (1) Based on the area of the study area L and the calculation requirements, the grid size is determined to be 300m×300m.
[0139] (2) The two types of text data, soil texture and crop type, are vectorized using the bag-of-words model.
[0140] (3) Using ArcGIS software, the phosphorus input, soil texture, daily rainfall, crop type, vegetation cover and DEM data layers were rasterized into a total of 80 raster units.
[0141] 3. Determining the direction of data loss and the main direction of data loss:
[0142] (1) Based on the D8 principle, calculate the elevation difference in each of the eight directions of each grid cell.
[0143] (2) If the elevation difference between the grid and the surrounding grid (grid elevation - surrounding grid elevation) is ≥0, it is considered a positive elevation difference. Phosphorus from the surrounding grid does not flow to the grid, thus determining the direction of loss.
[0144] (3) Calculate the 8 slope values for each grid cell, mark the grid cell with the maximum value as 1, and mark the remaining grid cells as 0, to obtain the main phosphorus outflow direction map, see Figure 4 It is shaped like a y.
[0145] 4. Churn Rate Prediction Model Construction:
[0146] (1) Using ArcGIS software, the phosphorus loss influencing factor data of the corresponding locations were extracted based on the latitude and longitude of the phosphorus loss rate data in the environmental database.
[0147] (2) The extracted phosphorus loss influencing factor data were normalized using the Min-Max normalization method to obtain five types of normalized loss influencing factor data: soil texture, daily rainfall, crop type, vegetation cover, and DEM.
[0148] (3) Using the data on leaching influencing factors obtained in the previous step as independent variables and all collected measured phosphorus leaching rates as dependent variables, the training set and test set are divided in a 7:3 ratio and input into the random forest model for model training. When the model R 2 When the value is greater than 0.7, the training is complete, and the churn rate prediction model is obtained.
[0149] (4) The center point of all raster cells was extracted using ArcGIS software. The environmental factor layer data affecting phosphorus loss was further extracted, normalized, and input into the loss rate prediction model to obtain phosphorus loss rate data.
[0150] (5) Among the 80 grid cells, 56 grid cells contain the collected measured phosphorus loss data (the mean of 39 grid cells needs to be calculated). Replace the phosphorus loss rate data results predicted by the model to obtain the phosphorus loss rate distribution map.
[0151] 5. Loss Calculation:
[0152] (1) Based on the elevation difference calculated in step 3, the grid cells are divided into two categories: elevation difference < 0 and elevation difference ≥ 0. When the elevation difference < 0, the flow tendency weight of the upstream grid to the grid is calculated. Weight × upstream grid phosphorus loss = phosphorus inflow to the grid.
[0153] (2) Phosphorus inflow of upstream grid + local input of grid = actual phosphorus input of grid. Calculate the actual phosphorus input of each grid cell separately.
[0154] (3) Based on the actual phosphorus input results and phosphorus loss rate distribution map calculated in the previous step, calculate the phosphorus loss of all grid cells and obtain the phosphorus loss rate distribution map, see Figure 5 .
[0155] (4) Based on the comprehensive analysis of the phosphorus main flow direction map and the phosphorus loss distribution map, it was determined that phosphorus L in the study area mainly flows from the upper left and right regions to the lower left region, forming a Y-shaped flow.
[0156] Based on the same inventive concept, this application also provides a device for determining nitrogen and phosphorus loss in regional farmland to implement the aforementioned method for determining nitrogen and phosphorus loss in regional farmland. The solution provided by this device is similar to the solution described in the above method. Therefore, the specific limitations of one or more embodiments of the device for determining nitrogen and phosphorus loss in regional farmland provided below can be found in the limitations of the method for determining nitrogen and phosphorus loss in regional farmland described above, and will not be repeated here.
[0157] In one exemplary embodiment, such as Figure 8 As shown, a device for determining nitrogen and phosphorus loss in regional farmland is provided, comprising:
[0158] The acquisition module is used to acquire data on nitrogen and phosphorus input and nitrogen and phosphorus loss influencing factors in farmland within the study area.
[0159] The splitting module is used to split the farmland in the study area into grid cells.
[0160] The loss direction determination module is used to determine the nitrogen and phosphorus loss direction of each grid cell in the farmland of the study area based on the elevation difference using the D8 algorithm.
[0161] The flow tendency weight determination module is used to determine the flow tendency weight based on the nitrogen and phosphorus loss direction of the grid cells and the elevation difference between the grid cells and the flow direction.
[0162] The prediction module is used to determine the nitrogen and phosphorus loss rate of each grid cell based on the nitrogen and phosphorus loss influencing factor data and the loss rate prediction model.
[0163] The module for determining the inflow of nitrogen and phosphorus into the upstream grid cells surrounding the current grid cell is used to determine the inflow of nitrogen and phosphorus into the upstream grid cells surrounding the current grid cell based on the flow tendency weight.
[0164] The actual nitrogen and phosphorus input determination module is used to determine the actual nitrogen and phosphorus input of each grid cell based on the nitrogen and phosphorus inflow of the upstream grid cells surrounding each grid cell and the nitrogen and phosphorus element input of each grid cell.
[0165] The module for determining nitrogen and phosphorus loss in each grid cell is used to determine the amount of nitrogen and phosphorus loss in each grid cell based on the actual nitrogen and phosphorus input and nitrogen and phosphorus loss rate.
[0166] The module for determining nitrogen and phosphorus loss in farmland within the study area is used to determine the nitrogen and phosphorus loss in farmland within the study area based on the nitrogen and phosphorus loss in each grid cell.
[0167] In one exemplary embodiment, a computer device is provided, which may be a server or a terminal, and its internal structure diagram may be as follows. Figure 9As shown, the computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs in the non-volatile storage media. The database stores data on nitrogen and phosphorus loss in regional farmland. The I / O interfaces are used for information exchange between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a method for determining nitrogen and phosphorus loss in regional farmland.
[0168] Those skilled in the art will understand that Figure 9 The structures shown are merely block diagrams of some structures related to the present application and do not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than shown in the figures, or combine certain components, or have different component arrangements. In an exemplary embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described method embodiments.
[0169] In one exemplary embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the above-described method embodiments.
[0170] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the above-described method embodiments.
[0171] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0172] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).
[0173] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0174] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0175] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for determining the amount of nitrogen and phosphorus loss from a regional farmland, characterized by, The methods for determining nitrogen and phosphorus loss from farmland in the aforementioned area include: Data on nitrogen and phosphorus input and nitrogen and phosphorus loss influencing factors were obtained from farmland in the study area. The farmland in the study area was divided into grid units; The direction of nitrogen and phosphorus loss in each grid cell of the farmland in the study area is determined by the D8 algorithm based on the elevation difference according to the grid cells. Before determining the direction of nitrogen and phosphorus loss in each grid cell of the farmland in the study area based on the elevation difference according to the D8 algorithm based on the grid cells, the method further includes: performing text vectorization and rasterization processing on the nitrogen and phosphorus element input and the nitrogen and phosphorus loss influencing factor data. The flow tendency weight is determined based on the direction of nitrogen and phosphorus loss from the grid cells and the elevation difference between the grid cells and the flow direction. The nitrogen and phosphorus loss rate of each grid cell is determined using a loss rate prediction model based on the nitrogen and phosphorus loss influencing factor data. The nitrogen and phosphorus inflow of the upstream grid cells surrounding the current grid cell is determined based on the flow tendency weight. The actual nitrogen and phosphorus input of each grid cell is determined based on the nitrogen and phosphorus inflow of the upstream grid cells surrounding each grid cell and the nitrogen and phosphorus element input of each grid cell. The amount of nitrogen and phosphorus loss for each grid cell is determined based on the actual nitrogen and phosphorus input and nitrogen and phosphorus loss rate. The amount of nitrogen and phosphorus loss from farmland in the study area was determined based on the amount of nitrogen and phosphorus loss in each grid cell.
2. The method of claim 1, wherein, The direction of nitrogen and phosphorus loss in each grid cell is determined based on the elevation difference using the D8 algorithm, specifically including: The elevation difference between each grid cell and its adjacent grid cells is calculated based on the D8 algorithm. The direction of nitrogen and phosphorus loss in each grid cell is determined based on the elevation difference.
3. The method of claim 1, wherein, The flow tendency weight is determined based on the direction of nitrogen and phosphorus loss from the grid cells and the elevation difference between the grid cells and the flow direction. Specifically, this includes: A grid cell whose flow direction is determined by the nitrogen and phosphorus loss direction of the grid cell; Determine the elevation difference between grid cells and flow direction grid cells based on grid cells and flow direction grid cells; The flow tendency weight of nitrogen and phosphorus loss from a grid cell to surrounding grid cells is determined based on the proportion of the elevation difference to the sum of the elevation differences between the grid cell and all grid cells to which the flow is to be directed.
4. The method of claim 1, wherein, Based on the nitrogen and phosphorus loss influencing factor data, the nitrogen and phosphorus loss rate of each grid cell is determined using a loss rate prediction model, specifically including: The nitrogen and phosphorus loss impact factor data of each grid cell are normalized to obtain normalized loss impact factor data. The normalized loss impact factor data is input into the loss rate prediction model for prediction, and the nitrogen and phosphorus loss rate of each grid cell is obtained. The loss rate prediction model is obtained by training the random forest model with the actual loss impact factor data as input and the measured nitrogen and phosphorus loss rate as output.
5. The method of claim 2, wherein, After determining the nitrogen and phosphorus loss of farmland in the study area based on the nitrogen and phosphorus loss of each grid cell, the following steps are also included: The direction of nitrogen and phosphorus flow in each grid cell is determined based on the elevation difference, and the slope value in each direction of each grid cell is calculated. Select the direction with the largest slope value of the grid cell as the main flow direction of the grid cell; The main loss directions of nitrogen and phosphorus in farmland in the study area were determined based on the main loss directions of the grid units. A distribution map of nitrogen and phosphorus loss in farmland within the study area was drawn based on the main loss direction of nitrogen and phosphorus in the study area.
6. A device for determining the amount of nitrogen and phosphorus loss from a regional farmland, characterized by, The device for determining nitrogen and phosphorus loss from farmland in the region includes: The acquisition module is used to acquire data on nitrogen and phosphorus input and nitrogen and phosphorus loss influencing factors in farmland within the study area. The splitting module is used to split the farmland in the study area into grid cells; The loss direction determination module is used to determine the nitrogen and phosphorus loss direction of each grid cell in the farmland of the study area based on the elevation difference using the D8 algorithm according to the grid cells; before determining the nitrogen and phosphorus loss direction of each grid cell in the farmland of the study area based on the elevation difference using the D8 algorithm according to the grid cells, it also includes: performing text vectorization processing and rasterization processing on the nitrogen and phosphorus element input and the nitrogen and phosphorus loss influencing factor data. The flow tendency weight determination module is used to determine the flow tendency weight based on the nitrogen and phosphorus loss direction of the grid cells and the elevation difference between the grid cells and the flow direction. The prediction module is used to determine the nitrogen and phosphorus loss rate of each grid cell based on the nitrogen and phosphorus loss influencing factor data and the loss rate prediction model. The module for determining the inflow of nitrogen and phosphorus into the upstream grid cells surrounding the current grid cell is used to determine the inflow of nitrogen and phosphorus into the upstream grid cells surrounding the current grid cell based on the flow tendency weight. The actual nitrogen and phosphorus input determination module is used to determine the actual nitrogen and phosphorus input of each grid cell based on the nitrogen and phosphorus inflow of the upstream grid cells surrounding each grid cell and the nitrogen and phosphorus element input of each grid cell. The module for determining nitrogen and phosphorus loss in each grid cell is used to determine the amount of nitrogen and phosphorus loss in each grid cell based on the actual nitrogen and phosphorus input and nitrogen and phosphorus loss rate. The module for determining nitrogen and phosphorus loss in farmland within the study area is used to determine the nitrogen and phosphorus loss in farmland within the study area based on the nitrogen and phosphorus loss in each grid cell.
7. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the method for determining nitrogen and phosphorus loss in regional farmland as described in any one of claims 1-5.
8. A computer-readable storage medium having stored thereon a computer program, characterized in that, When executed by a processor, the computer program implements the method for determining nitrogen and phosphorus loss in regional farmland as described in any one of claims 1-5.
9. A computer program product comprising a computer program, characterized in that, When executed by a processor, the computer program implements the method for determining nitrogen and phosphorus loss in regional farmland as described in any one of claims 1-5.