A Multi-Objective Composite Requirements-Based 3D Nearest Neighbor Search Method Using GIS and Python
By using a multi-objective composite requirement 3D nearest neighbor search method based on GIS and Python, this method solves the problem of insufficient optimization of target requirement conditions and geometric distance in existing technologies. It achieves efficient and flexible multi-objective screening and rapid calculation, and is applicable to scenarios such as building site selection, path planning, and resource allocation.
Patent Information
- Application Number
- CN202511165029.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-20
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2045-08-20
AI Technical Summary
Existing GIS tools cannot simultaneously optimize target requirements and geometric distances when dealing with building site selection, route planning, and resource allocation. This results in poorly optimized screening results and insufficient dynamic adaptability, leading to redundant and time-consuming calculations when dealing with large amounts of data.
A 3D nearest neighbor search method for multi-objective composite requirements based on GIS and Python is adopted. A regional analysis index system is constructed through GIS tools, and Python is used to perform efficient collaborative screening of multi-objective composite requirements conditions. This includes digitally processing the geographic 3D coordinates of the multi-objective center points, delineating the analysis area, constructing analysis units, and performing 3D distance calculations and condition screening.
It enables flexible handling of multiple objective requirements, improves dynamic adaptability, shortens computation time, and provides clear and orderly output results, making it suitable for scenarios such as building site selection, path planning, and resource allocation.
Smart Images

Figure CN120653664B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of geographic information systems and spatial data analysis technology, specifically to a three-dimensional nearest neighbor search method based on GIS and Python for multi-objective composite requirements. Background Technology
[0002] In fields such as building site selection, route planning, and resource allocation that require spatial optimization decisions, target requirement constraints and spatial proximity analysis are currently often handled separately. Either GIS tools are used to screen only the target requirement conditions, which often results in a lack of comparative optimization of the geometric distance of candidate points; or spatial proximity analysis is used only based on geometric distance, which lacks diverse target requirement constraints and easily causes the screening results to deviate from the actual needs.
[0003] Meanwhile, existing GIS tools for indicator factor analysis mostly rely on fixed thresholds for classification. Once the target requirements change dynamically, manual readjustment of the model is required, resulting in insufficient adaptability to dynamic changes in requirements and weak response capability to emergencies. In addition, current multi-objective complex requirement analysis mostly relies on manual step-by-step execution of attribute condition screening, which is computationally redundant and time-consuming when dealing with large amounts of data.
[0004] To address the technical challenge of traditional methods being unable to simultaneously handle attribute constraints and geometric distances, the research team of this invention proposes a multi-objective, composite-demand 3D nearest neighbor search method based on GIS and Python, applicable to scenarios requiring spatial optimization decisions such as building site selection, path planning, and resource allocation. Summary of the Invention
[0005] To overcome the shortcomings of existing technologies, the purpose of this invention is to provide a three-dimensional nearest neighbor search method for multi-objective composite requirements based on GIS and Python. Starting from digitized multi-objective composite requirements, a requirement analysis index system for a large area is established through GIS tools, and then efficient collaborative screening of multi-objective composite requirement conditions is performed based on Python.
[0006] A multi-objective, composite requirement-based 3D nearest neighbor search method using GIS and Python includes the following steps:
[0007] S10. Extract the geographic 3D coordinates of the center points of multiple targets through on-site positioning, digitally process the complex requirements of multiple targets, and output a target center point number, geographic 3D coordinates and a digital target requirement condition table file.
[0008] S20. Delineate the analysis area and define the analysis units;
[0009] S30. Construct a regional analysis indicator system based on GIS, specifically: extract regional data to analysis units based on GIS, convert the analysis units into search points, and output a table file containing search point numbers, geographic three-dimensional coordinates, and analysis factor values.
[0010] S40. Based on Python, read table data, parse target conditions to generate a numerical range matrix, and after three-dimensional distance calculation and condition filtering, output the nearest neighbor points that meet the requirements.
[0011] Furthermore, the extraction of the geographic three-dimensional coordinates of the center points of multiple targets and the digital processing of multi-target composite requirements specifically involves:
[0012] S11. Obtain the geographic three-dimensional coordinates of the center point of multiple targets. Obtain the geographic three-dimensional coordinates of the center point of the target through on-site positioning. The geographic three-dimensional coordinates include latitude and longitude coordinates and elevation coordinates, denoted as x1, y1 and z1 values.
[0013] S12. Select target demand conditions. The target demand conditions include numerical demand and textual demand. Numerical demand is recorded using numerical ranges, which include the three-dimensional distance limit to be searched. For example, within 1000m from the target point, it is directly recorded using numerical ranges, such as ">=0, <=1000" or ">=5, <=5, etc. Textual demand is represented by numbers to form digitized target demand conditions, such as using 10 to represent cultivated land, 20 to represent forest land, etc., and then using numerical ranges to record the specific demand conditions.
[0014] S13. Output the target point set information as a table file, and denot the table file name as Table 1. The target point set information includes the target center point number, geographic three-dimensional coordinates, and digitized target requirement conditions.
[0015] Furthermore, the process of delineating the analysis region and defining the analysis units specifically involves:
[0016] S21. Define the analysis area;
[0017] S22. Based on the target type and demand form of the analysis, select the basic analysis unit that matches it;
[0018] S23. Divide the defined analysis area according to the selected basic analysis unit.
[0019] Furthermore, based on the target type and demand form of the combined analysis, the corresponding basic analysis unit is selected, specifically: raster unit, administrative unit, regional unit, slope unit, and watershed unit. If convenient extraction of unit data values and specific, clear data representation are required, raster units can be considered. Administrative units are the basic units for land surveys and land use, suitable for government regional management evaluation and other demand forms. Regional units are suitable for land data surveys and analyses. Slope units have topographical continuity and minimal geological differences within the area, making them suitable for evaluating and analyzing slope geological hazards such as landslides and collapses. If the target demand is to reflect the comprehensive characteristics of the watershed as a whole, watershed units with a high degree of integration of hydrological and topographical conditions are recommended.
[0020] Further, step S30 specifically includes:
[0021] S31. Based on the form of target requirements, determine the analysis factors;
[0022] S32. Based on the collected elevation data, use GIS tools to establish a digital elevation model of the analysis area delineated in S20, and extract the elevation geometric values onto the basic analysis unit, denoted as z2 value;
[0023] S33. Based on the collected regional data, use GIS tools to extract the values of each analytical factor on the basic analysis unit;
[0024] S34. Use GIS tools to convert the basic analysis unit containing elevation geometric values and analysis factor values into its geometric center point as the search point, and calculate the latitude and longitude coordinate geometric values of each search point, denoted as x2 and y2 values;
[0025] S35. Use GIS tools to output the attribute table of the search point set, which contains the search point number, geographic three-dimensional coordinates, and analysis factor values, as a table file. The table file name is Table 2.
[0026] Further, step S30 specifically includes:
[0027] S31. Based on the form of target requirements, determine the analysis factors;
[0028] S32. Based on the collected elevation data, use the "Create TIN" and "TIN to Raster" functions of GIS tools to establish a digital elevation model of the analysis area delineated in S21, and use the "Zoning Statistics" function to extract the elevation geometric values to the basic analysis unit.
[0029] S33. Based on the collected regional data, use the "zoning statistics" function of GIS tools to extract the values of each analysis factor on the basic analysis unit;
[0030] S34. Use the "Element to Point" function of GIS tools to convert the basic analysis unit containing elevation geometric values and analysis factor values into its geometric center point as the search point, and use the "Computational Geometry" function to calculate the latitude and longitude coordinate geometric values of each search point.
[0031] S35. Use the "Table to Excel" function of the GIS tool to output the attribute table of the search point set, which contains the search point number, geographic three-dimensional coordinates, and analysis factor values, as a table file.
[0032] Furthermore, the determination of analysis factors based on the target demand form is as follows: For example, the analysis factors for the target demand form of the construction camp site closest to the project site are generally slope, road distance, land use type, and river distance, etc.; the analysis factors for the target demand form of the home purchase or rental closest to the workplace are generally shopping mall distance, park distance, hospital distance, school distance, and house price, etc.; the analysis factors for the target demand form of the tourist attraction closest to home are generally positive reviews, travel costs, accommodation costs, scenic spot level, and altitude, etc.
[0033] Furthermore, the method of implementing 3D nearest neighbor search analysis based on Python to capture nearest neighbor points that meet the target requirements specifically includes:
[0034] S41. Use Python's read function to import the table file data exported from S10 and S30;
[0035] S42. Data preprocessing: First, the requirement conditions of the structured target points are parsed. The range condition strings in the target points are split into minimum and maximum values using code. Then, operators and thresholds are extracted using regular expressions to generate a numerical range matrix.
[0036] S43. Data merging and calculation: Perform data cross-merging, and then calculate the three-dimensional distance between the target point and the search point that meets the target requirements.
[0037] S44. Data filtering: Based on the collaborative filtering of requirement constraints and the three-dimensional distance limit to be searched, records that meet all requirement conditions are filtered.
[0038] S45. Data is hierarchically sorted, grouped by target point number, and then sorted in ascending order by the three-dimensional distance between the target point and the search point that meets the target requirements.
[0039] S46. Output the data results. Output the final results as a table file, which will show the nearest neighbor locations that meet the target requirements.
[0040] Furthermore, the method of implementing 3D nearest neighbor search analysis based on Python to capture nearest neighbor points that meet the target requirements specifically includes:
[0041] S41. Use the read function in Python's Pandas library to import the table file data exported from S10 and S30. Table 1 contains the following key fields: target center point number, geographic 3D coordinates (x1, y1, and z1 values), digitized target requirements, and the 3D distance boundary data to be searched; Table 2 contains the following key fields: search point number, geographic 3D coordinates (x2, y2, and z2 values), and search data corresponding to various analysis factors.
[0042] S42. Data preprocessing: First, the requirement conditions of the structured target points are parsed. The range condition strings in the target points are split into minimum and maximum values using code and stored in the format of the lower limit operator min and the upper limit operator max. Then, the operators and thresholds are extracted through regular expressions to generate a numerical range matrix.
[0043] S43. Data merging and calculation: Use the merge function to perform data cross-merging (Cartesian product), and then use NumPy to calculate the Euclidean distance between the target point and the search point that meets the target requirements.
[0044] S44. Data filtering: Collaborative filtering based on requirement constraints and the three-dimensional distance limit to be searched; using Boolean indexes to filter records that meet all requirement conditions; using the "&" operator to combine conditions.
[0045] S45. Data is hierarchically sorted. The groupby function is used to sort and group the data by target point number, and then sorted in ascending order by the three-dimensional distance between the target point and the search point that meets the target requirements.
[0046] S46. Output the data results. Output the final results as a table file, which will show the nearest neighbor locations that meet the target requirements.
[0047] Furthermore, the table file can be a text file, a CSV file, or an Excel file.
[0048] The beneficial effects of this invention are:
[0049] 1. The method of this invention flexibly digitizes various forms of demand conditions for multiple objectives, and constructs an indicator analysis system for a large area under the guidance of target demand through GIS tools, which is highly adaptable to dynamic changes in demand.
[0050] 2. The method of this invention is based on Python for multi-condition collaborative filtering of large-scale data. It has a fast computation speed and solves the technical problem that traditional methods cannot handle attribute constraints and geometric distances at the same time. Furthermore, the output results are clearer and more orderly through grouping and sorting. It is suitable for scenarios that require spatial optimization decisions, such as building site selection, path planning, and resource allocation. Attached Figure Description
[0051] Figure 1 This is a flowchart illustrating the multi-objective composite requirement three-dimensional nearest neighbor search method based on GIS and Python provided by the present invention. Detailed Implementation
[0052] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. The illustrative embodiments and descriptions of the present invention are used to explain the present invention, but are not intended to limit the present invention.
[0053] Please see Figure 1 A flowchart illustrating a multi-objective, composite 3D nearest neighbor search method based on GIS and Python, comprising the following steps:
[0054] Taking the site selection of temporary construction camps for water conservancy projects and their ancillary structures in Xingyi City, Qianxinan Buyi and Miao Autonomous Prefecture, Guizhou Province as an example, the technical solution of this invention is illustrated below:
[0055] ;
[0056] S1. Extract the 3D geographic coordinates of the center points of multiple targets and digitally process multi-target composite requirements:
[0057] S11. Obtain the geographic 3D coordinates of the center points of multiple targets. Here, 20 locations in Xingyi City were randomly selected as the target center points for site selection. The geographic 3D coordinates of these 20 target center points were obtained through on-site positioning. The geographic 3D coordinates include latitude and longitude geometric values and elevation geometric values, i.e. , and value;
[0058] S12. This time, slope, fault distance, land use type, road distance, river distance, and the three-dimensional distance limit to be searched were selected as the target requirement conditions. Among them, slope, fault distance, road distance, river distance, and the three-dimensional distance limit to be searched are numerical requirements, which are directly recorded as numerical ranges; land use type is a textual requirement, which is represented by numbers respectively: 10 for cultivated land; 20 for forest land; 30 for grassland; 40 for shrubland; 50 for wetland; 60 for artificial surface; 70 for water body.
[0059] S13. Output the target point set information of the above 20 locations, which contains the target center point number, geographic three-dimensional coordinates, digitized target requirement conditions, and three-dimensional distance boundary data to be searched, as an Excel file (.xlsx format). The table file name is Table 1.
[0060] S2, Delineate the analysis region and define the analysis units:
[0061] S21. Based on project needs and actual circumstances, Xingyi City will be the analysis area for this study.
[0062] S22. Since the target type of the analysis is a building, which belongs to the plot type of project, the grid cell is selected as the basic analysis cell.
[0063] S23. Divide the Xingyi City area into a grid of 100m×100m.
[0064] S3, Constructing a regional analysis indicator system based on GIS:
[0065] S31. Based on the target demand form, the analysis factors are determined to be slope, fault distance, land use category, road distance and river distance;
[0066] S32. Based on the collected elevation data, use the "Create TIN" and "TIN to Raster" functions of GIS tools to establish a digital elevation model of the Xingyi City area, and use the "Zoning Statistics" function to extract the elevation geometric values onto 100m×100m raster cells, i.e. value;
[0067] S33. Based on the collected regional data, use the "zoning statistics" function of GIS tools to extract the values of each analysis factor on the raster cell;
[0068] S34. Use the "Raster to Point" or "Feature to Point" function of GIS tools to convert raster cells containing elevation geometric values and analysis factor values into their geometric center points (i.e., search points), and use the "Computational Geometry" function to calculate the latitude and longitude coordinates of each search point. and value;
[0069] S35. Use the "Table to Excel" function of the GIS tool to output the attribute table of the search point set containing the search point number, geographic three-dimensional coordinates and analysis factor values as an Excel file (.xlsx format). The table file name is Table 2.
[0070] ;
[0071] S4, based on Python, implements 3D nearest neighbor search analysis to capture nearest neighbor points that meet the target requirements:
[0072] S41. Use the Excel reading function in Python's Pandas library to import the data from Table 1 and Table 2.
[0073] S42. Data Preprocessing. Specifically: First, the requirement conditions for the structured target points are parsed. The range condition strings in the target points are split into minimum and maximum values using code, stored in the format of "lower limit operator (min), upper limit operator (max)". Then, operators and thresholds are extracted using regular expressions to generate a numerical range matrix.
[0074] S43. Data merging and calculation: First, the merge function is used to perform data cross-merging (Cartesian product). Then, the three-dimensional distance between the target point and the search points that meet the target requirements is calculated using NumPy to obtain the Euclidean distance.
[0075] S44. Data filtering, which is a collaborative filtering based on requirement constraints and the 3D distance limits to be searched. Specifically, it uses Boolean indexes to filter records that meet all requirement conditions, that is, for each requirement condition, it checks whether the actual value of the search point is within the requirement range of the target point. The "&" operator is used to combine conditions.
[0076] S45. Data hierarchical sorting, that is, first use the groupby function to sort and group by target point number, and then sort in ascending order by the three-dimensional distance between the target point and the search point that meets the target requirements.
[0077] S46. Data Result Output: Output the final results as an Excel file (.xlsx format), and name the table file Table 3. It should be noted that the search points selected in the results are the geometric center points of the plots that meet the site selection requirements for the target houses, i.e., the geometric center points of the 100*100m grid cells.
[0078] .
[0079] Although the present invention has been described in detail above with general descriptions and specific embodiments, the scope of protection of the present invention is not limited thereto. Modifications or improvements can be made to the present invention, which will be obvious to those skilled in the art. Therefore, all such modifications or improvements made without departing from the spirit of the present invention fall within the scope of protection claimed by the present invention.
Claims
1. A multi-objective, composite requirement-based three-dimensional nearest neighbor search method using GIS and Python, characterized in that, Includes the following steps: S10. Extract the geographic 3D coordinates of the center points of multiple targets through on-site positioning, digitally process the complex requirements of multiple targets, and output a target center point number, geographic 3D coordinates and a digital target requirement condition table file. S20. Define the analysis area and delineate the analysis units; S30. Construct a regional analysis indicator system based on GIS, specifically: extract regional data to analysis units based on GIS, convert the analysis units into search points, and output a table file containing search point numbers, geographic three-dimensional coordinates, and analysis factor values. Specifically: S31. Based on the form of target requirements, determine the analysis factors; S32. Based on the collected elevation data, use GIS tools to build a digital elevation model of the analysis area delineated in S20, and extract the elevation geometric values to the basic analysis unit; S33. Based on the collected regional data, use GIS tools to extract the values of each analysis factor on the basic analysis unit; S34. Use GIS tools to convert the basic analysis unit containing elevation geometric values and analysis factor values into its geometric center point as the search point, and calculate the latitude and longitude coordinate geometric values of each search point; S35. Use GIS tools to output the attribute table of the search point set, which contains the search point number, geographic three-dimensional coordinates, and analysis factor values, as a table file; S40. Based on Python, read table data, parse target conditions to generate a numerical range matrix, and after three-dimensional distance calculation and condition filtering, output the nearest neighbor points that meet the requirements. Specifically: S41. Use Python's read function to import the table file data output by S10 and S30; S42. Data preprocessing: First, the requirement conditions of the structured target points are parsed. The range condition strings in the target points are split into minimum and maximum values using code. Then, operators and thresholds are extracted using regular expressions to generate a numerical range matrix. S43. Data merging and calculation: Perform data cross-merging, and then calculate the three-dimensional distance between the target point and the search point that meets the target requirements. S44. Data filtering: Based on the collaborative filtering of requirement constraints and the three-dimensional distance limit to be searched, records that meet all requirement conditions are filtered. S45. Data is hierarchically sorted, grouped by target point number, and then sorted in ascending order by the three-dimensional distance between the target point and the search point that meets the target requirements. S46. Output the data results. Output the final results as a table file, which will show the nearest neighbor locations that meet the target requirements.
2. The multi-objective composite requirement three-dimensional nearest neighbor search method based on GIS and Python according to claim 1, characterized in that, Step S10 specifically involves: S11. Obtain the geographic three-dimensional coordinates of the center points of multiple targets. Extract the geographic three-dimensional coordinates of the center points of the targets through on-site positioning. The geographic three-dimensional coordinates include latitude and longitude coordinates and elevation coordinates. S12. Select target requirement conditions, which include numerical requirements and textual requirements; S13. Output the target point set information as a table file. The target point set information includes the target center point number, geographic three-dimensional coordinates, and digitized target requirement conditions.
3. The multi-objective composite requirement three-dimensional nearest neighbor search method based on GIS and Python according to claim 2, characterized in that, In step S12, digital requirements are recorded using number ranges, while textual requirements are replaced with numbers to form digitized target requirement conditions.
4. The multi-objective composite requirement three-dimensional nearest neighbor search method based on GIS and Python according to claim 1, characterized in that, Step S20 specifically involves: S21. Define the analysis area; S22. Based on the target type and demand form of the analysis, select the basic analysis unit that matches it; S23. Divide the defined analysis area according to the selected basic analysis unit.
5. The multi-objective composite requirement three-dimensional nearest neighbor search method based on GIS and Python according to claim 4, characterized in that, The analysis combines the target type and demand form, and selects the basic analysis unit that matches it, specifically the grid unit, administrative unit, regional unit, slope unit and watershed unit.
6. The multi-objective composite requirement three-dimensional nearest neighbor search method based on GIS and Python according to claim 1, characterized in that, Step S40 specifically includes: S41. Use the read function in Python's Pandas library to import the tabular data exported from S10 and S30; S42. Data preprocessing: First, the requirement conditions of the structured target points are parsed. The range condition strings in the target points are split into minimum and maximum values using code and stored in the format of the lower limit operator min and the upper limit operator max. Then, the operators and thresholds are extracted through regular expressions to generate a numerical range matrix. S43. Data merging and calculation: The merge function is used to cross-merge data. Then, the three-dimensional distance between the target point and the search point that meets the target requirements is calculated as Euclidean distance using NumPy. S44. Data filtering: Collaborative filtering based on requirement constraints and the three-dimensional distance limits to be searched; using Boolean indexes to filter records that meet all requirement conditions; using the "&" operator to combine conditions. S45. Data is hierarchically sorted. The groupby function is used to sort and group the data by target point number, and then sorted in ascending order by the three-dimensional distance between the target point and the search point that meets the target requirements. S46. Output the data results. Output the final results as a table file, which will show the nearest neighbor locations that meet the target requirements.
7. The multi-objective composite requirement three-dimensional nearest neighbor search method based on GIS and Python according to claim 1, characterized in that, The table file can be a text file, a CSV file, or an Excel file.
Citation Information
Patent Citations
Three-dimensional dispersion point cloud topological neighbor data query method
CN101404061A
Power facility line selection method and system based on GIS and data analysis
CN117610205A