Multi-target compound type demand three-dimensional neighbor search method based on GIS and Python
Through the multi-objective and complex demand three-dimensional neighbor search method of GIS and Python, multi-objective demands are digitally processed, a regional analysis index system is constructed, and Python is combined for efficient screening, which solves the problem of insufficient optimization of target demands and geometric distances in existing technologies and improves calculation efficiency and clarity of results.
Patent Information
- Application Number
- CN202511165029.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-20
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2045-08-20
AI Technical Summary
Existing GIS tools are unable to simultaneously optimize target demand conditions and geometric distances when dealing with areas such as building site selection, route planning, and resource allocation. This results in poorly optimized screening results, insufficient dynamic adaptability, redundant calculations, and a long processing time, especially when dealing with large amounts of data.
A multi-objective and complex three-dimensional neighbor search method based on GIS and Python is adopted. By digitizing the geographic three-dimensional coordinates of multi-objective center points, a regional analysis index system is constructed. Python is used for efficient multi-objective conditional screening, and combined with three-dimensional distance calculation and conditional constraints, collaborative screening of neighbor points is achieved.
It achieves flexible handling of multi-objective requirements, improves dynamic adaptability, shortens calculation time, and outputs clearer and more orderly results. It is suitable for spatial optimization decision-making scenarios such as building site selection, path planning, and resource allocation.
Smart Images

Figure CN120653664A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of geographic information systems and spatial data analysis technology, and in particular to a multi-objective composite demand three-dimensional nearest neighbor search method based on GIS and Python. Background Art
[0002] For areas that require spatial optimization decisions, such as building site selection, route planning, and resource allocation, target demand condition constraints and spatial proximity analysis are currently mostly processed separately. Alternatively, only target demand condition screening is performed based on GIS tools, often resulting in a lack of comparative optimization of geometric distances for candidate points. Alternatively, only spatial proximity analysis is performed based on geometric distances, lacking diverse target demand condition constraints, which can easily cause the screening results to deviate from actual needs.
[0003] At the same time, existing GIS tools for indicator factor analysis often rely on fixed thresholds for grading. Dynamic changes in target demand require manual readjustment of the model, resulting in insufficient adaptability to dynamic demand changes and weak emergency response capabilities. Furthermore, current multi-objective, complex demand analysis often relies on manual, step-by-step attribute condition screening, which, when faced with large volumes of data, results in redundant and time-consuming calculations.
[0004] To solve the technical problem that traditional methods cannot handle attribute constraints and geometric distances at the same time, the research team of this invention proposed a multi-objective composite demand three-dimensional neighbor search method based on GIS and Python, which is suitable for scenarios that require spatial optimization decisions, such as building site selection, path planning, and resource allocation. Summary of the Invention
[0005] In order to overcome the shortcomings of the existing technology, the purpose of the present invention is to provide a three-dimensional neighbor search method for multi-objective complex demands based on GIS and Python. Starting from the digital multi-objective complex demands, a demand analysis index system for a large area is established through GIS tools, and then efficient collaborative screening of multi-objective complex demand conditions is carried out based on Python.
[0006] The multi-objective and complex three-dimensional neighbor search method based on GIS and Python includes the following steps: S10, extracting the geographic three-dimensional coordinates of multiple target center points through on-site positioning, digitally processing the multi-target composite requirements, and outputting a table file including the target center point number, geographic three-dimensional coordinates, and digital target requirement condition; S20, delineate the analysis area and define the analysis units; S30, constructing a regional analysis indicator system based on GIS, specifically: extracting regional data into analysis units based on GIS, converting the analysis units into search points, and outputting a table file containing search point numbers, geographic three-dimensional coordinates, and analysis factor values; S40, based on Python, reads table data, analyzes target conditions to generate a numerical range matrix, and after three-dimensional distance calculation and condition screening, outputs neighboring points that meet the requirements.
[0007] Furthermore, the extraction of the geographical three-dimensional coordinates of the multi-target center points and the digital processing of the multi-target composite requirements are specifically as follows: S11, obtaining the geographic three-dimensional coordinates of the center points of multiple targets, obtaining the geographic three-dimensional coordinates of the target center points through on-site positioning, the geographic three-dimensional coordinates including the latitude and longitude coordinate geometric values and the elevation geometric values, recorded as x1, y1 and z1 values; S12. Select target demand conditions. The target demand conditions include numerical demands and text demands. Numeric demands are recorded using numerical intervals, including the three-dimensional distance limits to be searched. For example, within a range of 1000m from the target point, numerical intervals are directly recorded, such as “>=0, <=1000” or “>=5, <=5”. Text demands are replaced by numbers to form digital target demand conditions, such as using 10 to replace cultivated land and 20 to replace forest land. Specific demand conditions are then recorded using numerical intervals. S13. Output the target point set information as a table file, the table file name is recorded as Table 1, and the target point set information includes the target center point number, geographic three-dimensional coordinates and digital target requirement conditions.
[0008] Furthermore, the delineation of the analysis area and the delineation of the analysis unit are specifically as follows: 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 circled analysis area according to the selected basic analysis units.
[0009] Furthermore, the above-mentioned combination of the target type and the demand form of the analysis selects the corresponding basic analysis units, specifically, grid units, administrative units, regional units, slope units, and watershed units. If the unit data value extraction is convenient and the data expression is specific and clear, the grid unit can be considered. The administrative unit is the basic unit for land survey and land use, suitable for demand forms such as government regional management evaluation. The regional unit is suitable for land data survey and analysis. The slope unit has topographic continuity and the geological differences within the area are not large, which is suitable for the evaluation and analysis of slope geological hazards such as landslides and collapses. If the target demand is to reflect the comprehensive characteristics of the watershed as a whole, the watershed unit with a high degree of integration of hydrological conditions and topographic conditions is recommended.
[0010] Furthermore, the step S30 is specifically as follows: S31. Determine analysis factors based on target demand form; 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 geometry value to the basic analysis unit, which is recorded as the z2 value; S33. Based on the collected regional data, use GIS tools to extract the values of each analysis factor on the basic analysis unit; S34, using GIS tools to convert the basic analysis unit containing the elevation geometry value and the analysis factor value into its geometric center point as the search point, and calculate the latitude and longitude coordinate geometry values of each search point, recorded as x2 and y2 values; S35. Use GIS tools to output the attribute table of the search point set containing the search point number, geographic three-dimensional coordinates, and analysis factor values into a table file. The table file name is recorded as Table 2.
[0011] Furthermore, the step S30 is specifically as follows: S31. Determine analysis factors based on target demand form; S32. Based on the collected elevation data, use the "Create TIN" and "TIN to Raster" functions of the GIS tool to build a digital elevation model of the analysis area delineated in S21, and use the "Zoning Statistics" function to extract the elevation geometry values to the basic analysis unit; S33. Based on the collected regional data, use the "zonal statistics" function of the GIS tool to extract the values of each analysis factor on the basic analysis unit; S34. Use the "Convert Elements to Points" function of the GIS tool to convert the basic analysis unit containing the elevation geometry value and the analysis factor value into its geometric center point as the search point, and use the "Calculate Geometry" function to calculate the latitude and longitude coordinate geometry values of each search point; S35. Use the "Convert 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 value into a table file.
[0012] Furthermore, the analysis factors are determined based on the target demand form. Specifically, 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; the analysis factors for the target demand form of buying or renting a house closest to the workplace are generally shopping mall distance, park distance, hospital distance, school distance and house price; the analysis factors for the target demand form of the tourist attraction closest to home are generally praise, travel cost, accommodation cost, scenic spot level and altitude.
[0013] Furthermore, the three-dimensional nearest neighbor search analysis is implemented based on Python to capture the nearest neighbor points that meet the target requirements, specifically: S41, using Python reading function to import the table file data exported in S10 and S30; S42. Data preprocessing: First, the target point requirement condition analysis is structured. The range condition string in the target point is split into minimum and maximum values using code. Then, the operator and threshold are extracted through regular expressions to generate a numerical range matrix. S43, data merging and calculation, performing cross-merging of the data, and then calculating the three-dimensional distance between the target point and the search point that meets the target requirements; S44, data screening, based on collaborative filtering of requirement constraints and the three-dimensional distance limit to be searched, screening records that meet all requirement conditions; S45. sorting the data in layers, sorting and grouping by target point number, and then sorting in ascending order by the three-dimensional distance between the target point and the search point that meets the target requirement; S46. Data result output: the final result is output as a table file, that is, the neighboring points that meet the target requirements are obtained.
[0014] Furthermore, the three-dimensional nearest neighbor search analysis is implemented based on Python to capture the nearest neighbor points that meet the target requirements, specifically: S41. Use the reading function in Python's Pandas library to import the table file data exported by S10 and S30. The data in Table 1 contains the following key fields: target center point number, geographic three-dimensional coordinates (x1, y1, and z1 values), digitized target requirement conditions, and three-dimensional distance boundary data to be searched; the data in Table 2 contains the following key fields: search point number, geographic three-dimensional coordinates (x2, y2, and z2 values), and search data corresponding to various analysis factors.
[0015] S42. Data preprocessing: First, the target point requirement condition analysis is structured. The range condition string in the target point is split into minimum and maximum values using code. The values are stored in the format of the min operator and the max operator. Then, the operators and thresholds are extracted using regular expressions to generate a numerical range matrix. S43, data merging and calculation, using the merge function to perform data cross-merging (Cartesian product), and then using NumPy to calculate the Euclidean distance between the target point and the search point that meets the target requirements; S44, data screening, based on collaborative filtering of requirement constraints and the three-dimensional distance limit to be searched, using Boolean indexing to filter records that meet all requirement conditions, and using the "&" operator to combine conditions; S45. Sort the data hierarchically by using 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; S46. Data result output: the final result is output as a table file, that is, the neighboring points that meet the target requirements are obtained.
[0016] Furthermore, the table file is a text file, a CSV file or an Excel file.
[0017] The beneficial effects of the present invention are: 1. The method of the present invention flexibly digitally processes various forms of demand conditions for multiple targets, and constructs an indicator analysis system for a large area under the guidance of target demand through GIS tools, which has strong adaptability to dynamic changes in demand.
[0018] 2. The method of the present invention performs multi-condition collaborative screening of large-scale data based on Python, has a fast calculation speed, and solves the technical problem that traditional methods cannot simultaneously handle attribute constraints and geometric distances. In addition, 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. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 This is a flow chart of the multi-objective, composite-demand three-dimensional nearest neighbor search method based on GIS and Python provided by the present invention. DETAILED DESCRIPTION
[0020] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. The exemplary embodiments and descriptions of the present invention are used to explain the present invention but are not intended to limit the present invention.
[0021] See also Figure 1 Schematic diagram of the method flow, a multi-objective and complex demand 3D nearest neighbor search method based on GIS and Python, including the following steps: The technical solution of the present invention is illustrated by taking the site selection of a temporary construction camp for a water conservancy project and its ancillary structures in Xingyi City, Qianxinan Buyi and Miao Autonomous Prefecture, Guizhou Province as an example: ; S1. Extract the geographic three-dimensional coordinates of multiple target center points and digitally process multi-target complex requirements: S11. Obtain the geographic three-dimensional coordinates of multiple target center points. Here, 20 locations in Xingyi City were randomly selected as the target center points for site selection. The geographic three-dimensional coordinates of the above 20 target center points were obtained through on-site positioning. The geographic three-dimensional coordinates include the latitude and longitude coordinate geometric values and the elevation geometric values, namely 、 and value; S12. This time, we selected slope, fault distance, land use type, road distance, river distance, and the 3D distance limit to search as target requirements. Slope, fault distance, road distance, river distance, and the 3D distance limit to search are numerical requirements and are recorded directly using numerical intervals. For textual requirements, land use type is replaced with numbers, specifically: 10 for cultivated land; 20 for forest land; 30 for grassland; 40 for shrubland; 50 for wetland; 60 for artificial surface; and 70 for water bodies.
[0022] S13. Output the target point set information of the above 20 locations, including target center point numbers, geographic three-dimensional coordinates, digitized target requirement conditions, and three-dimensional distance limit data to be searched, into an Excel file (.xlsx format). The table file name is recorded as Table 1.
[0023] S2, define the analysis area and delineate the analysis units: S21. Based on the project needs and actual conditions, Xingyi City is selected as the analysis area. S22. The target type of the combined analysis is a house, which belongs to the land-based project, so the grid unit is selected as the basic analysis unit; S23. Divide the Xingyi City area into 100m×100m grids.
[0024] S3, building a regional analysis indicator system based on GIS: 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; S32. Based on the collected elevation data, use the "Create TIN" and "TIN to Raster" functions of the GIS tool to build a digital elevation model of the Xingyi City area, and use the "Zoning Statistics" function to extract the elevation geometry values to a 100m×100m grid cell, that is, value; S33. Based on the collected regional data, the "zonal statistics" function of the GIS tool is used to extract the values of each analysis factor on the grid cell; S34. Use the "Raster to Point" or "Feature to Point" function of the GIS tool to convert the grid cells containing the elevation geometry value and the analysis factor value into their geometric center points (i.e., search points), and use the "Calculate Geometry" function to calculate the latitude and longitude coordinate geometry values of each search point, i.e. and value; S35. Use the "Convert Table to Excel" function of the GIS tool to export the attribute table of the search point set containing the search point number, geographic 3D coordinates, and analysis factor values into an Excel file (.xlsx format). The table file name is recorded as Table 2. ; S4, based on Python, implements 3D neighbor search analysis to capture neighboring points that meet the target requirements: S41. Use Python's Pandas library to read Excel functions and import the data in Table 1 and Table 2.
[0025] S42. Data preprocessing. Specifically, first, the target point's requirement conditions are parsed. Code is used to split the target point's range condition string into minimum and maximum values, storing them in a "min" (lower bound operator) and "max" (upper bound operator) format. Then, regular expressions are used to extract operators and thresholds, generating a numerical range matrix.
[0026] S43. Data merging and calculation. Specifically, first, use the merge function to perform cross-merging (Cartesian product) of the data. Then, use NumPy to calculate the Euclidean distance between the target point and the search point that meets the target requirements.
[0027] S44. Data filtering involves collaborative filtering based on the constraints of the search criteria and the three-dimensional distance limits to be searched. Specifically, Boolean indexing is used to filter records that meet all the criteria. For each criterion, the actual value of the search point is checked to see if it falls within the target point's required range. The "&" operator is used to combine criteria.
[0028] S45. Hierarchical sorting of data, that is, first using the groupby function to sort and group by target point number, and then sorting in ascending order by the three-dimensional distance between the target point and the search point that meets the target requirements.
[0029] S46. Output the data results, that is, output the final results to an Excel file (.xlsx format), and the table file name is recorded as Table 3. It should be noted that the search point selected in the results is the geometric center point of the plot that meets the target house site selection requirements, that is, the geometric center point of the 100*100m grid cell; .
[0030] Although the present invention has been described in detail above using general descriptions and specific embodiments, the scope of protection of the present invention is not limited thereto. It will be apparent to those skilled in the art that modifications or improvements may be made based on the present invention. Therefore, such modifications or improvements that do not depart from the spirit of the present invention are intended to fall within the scope of protection claimed by the present invention.
Claims
1. A multi-objective composite demand three-dimensional neighbor search method based on GIS and Python, characterized by: The following steps are involved: S10, extracting the geographic three-dimensional coordinates of multiple target center points through on-site positioning, digitally processing the multi-target composite requirements, and outputting a table file including the target center point number, geographic three-dimensional coordinates, and digital target requirement condition; S20, delineate the analysis area and define the analysis units; S30, constructing a regional analysis indicator system based on GIS, specifically: extracting regional data into analysis units based on GIS, converting the analysis units into search points, and outputting a table file containing search point numbers, geographic three-dimensional coordinates, and analysis factor values; S40, based on Python, reads table data, analyzes target conditions to generate a numerical range matrix, and after three-dimensional distance calculation and condition screening, outputs neighboring points that meet the requirements.
2. The multi-objective composite demand three-dimensional neighbor search method based on GIS and Python according to claim 1 is characterized in that: The step S10 is specifically as follows: S11, obtaining the geographic three-dimensional coordinates of the center points of multiple targets, extracting the geographic three-dimensional coordinates of the target center points through on-site positioning, the geographic three-dimensional coordinates including latitude and longitude coordinate geometric values and elevation geometric values; S12. Select target requirement conditions, where the target requirement conditions include numerical requirements and text requirements; S13. Output the target point set information as a table file, wherein 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 demand three-dimensional neighbor search method based on GIS and Python according to claim 2 is characterized in that: In step S12, digital requirements are recorded using digital intervals, and text requirements are respectively replaced by numbers to form digital target requirement conditions.
4. The multi-objective composite demand three-dimensional nearest neighbor search method based on GIS and Python according to claim 1 is characterized in that: The step S20 is specifically as follows: 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 circled analysis area according to the selected basic analysis units.
5. The multi-objective composite demand three-dimensional nearest neighbor search method based on GIS and Python according to claim 4 is characterized in that: The target type and demand form of the combined analysis are used to select basic analysis units that match them, specifically, grid units, administrative units, regional units, slope units and watershed units.
6. The multi-objective composite demand three-dimensional nearest neighbor search method based on GIS and Python according to claim 1 is characterized in that: The step S30 is specifically as follows: S31. Determine analysis factors based on target demand form; 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 elevation geometry 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, using GIS tools to convert the basic analysis units containing the elevation geometry values and analysis factor values into their geometric center points as search points, and calculate the latitude and longitude coordinate geometry values of each search point; S35. Use GIS tools to output the attribute table of the search point set containing the search point number, geographic three-dimensional coordinates and analysis factor value into a table file.
7. The multi-objective composite demand three-dimensional nearest neighbor search method based on GIS and Python according to claim 1 is characterized in that: The step S40 is specifically as follows: S41, using Python reading function to import the table file data output by S10 and S30; S42. Data preprocessing: First, the target point requirement condition analysis is structured. The range condition string in the target point is split into minimum and maximum values using code. Then, the operator and threshold are extracted through regular expressions to generate a numerical range matrix. S43, data merging and calculation, performing cross-merging of the data, and then calculating the three-dimensional distance between the target point and the search point that meets the target requirements; S44, data screening, based on collaborative filtering of requirement constraints and the three-dimensional distance limit to be searched, screening records that meet all requirement conditions; S45. sorting the data in layers, sorting and grouping by target point number, and then sorting in ascending order by the three-dimensional distance between the target point and the search point that meets the target requirement; S46. Data result output: the final result is output as a table file, that is, the neighboring points that meet the target requirements are obtained.
8. The multi-objective composite demand three-dimensional nearest neighbor search method based on GIS and Python according to claim 7 is characterized in that: The step S40 is specifically as follows: S41. Use the read function in Python's Pandas library to import the table file data exported in S10 and S30. S42. Data preprocessing: First, the target point requirement condition analysis is structured. The range condition string in the target point is split into minimum and maximum values using code. The values are stored in the format of the min operator and the max operator. Then, the operators and thresholds are extracted using regular expressions to generate a numerical range matrix. S43, data merging and calculation, using the merge function to cross-merge the data, and then using NumPy to calculate the Euclidean distance between the target point and the search point that meets the target requirements; S44, data screening, based on collaborative filtering of requirement constraints and the three-dimensional distance limit to be searched, using Boolean indexing to filter records that meet all requirement conditions, and using the "&" operator to combine conditions; S45. Sort the data hierarchically by using 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; S46. Data result output: the final result is output as a table file, that is, the neighboring points that meet the target requirements are obtained.
9. The multi-objective composite demand three-dimensional nearest neighbor search method based on GIS and Python according to claim 7 is characterized in that: The table file is 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
Video patrol method and system based on GIS space search and linear sorting
CN113868320A
Power facility line selection method and system based on GIS and data analysis
CN117610205A
Method and device for generating distribution characteristics of multiple meteorological elements, equipment and medium
CN118245770A
GIS information retrieval method using dynamic k-nearest neighbor search algorithm in an obstacle environment
US20230195803A1