A GIS-based area measurement method and system
By using GIS's fast rejection algorithm and cross-sectional verification, polygonal entities are generated and their areas are calculated, solving the anomaly problem of traditional GIS area measurement methods in complex situations and achieving more efficient and accurate area measurement.
Patent Information
- Application Number
- CN202211580445.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-09
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2042-12-09
AI Technical Summary
Traditional GIS area measurement methods are prone to abnormal results in complex situations, such as the area being 0 or negative when graphics overlap, and the results of similar graphics differing greatly, leading to inaccurate measurements.
A GIS-based area measurement method is adopted. Input coordinates that do not conform to the rules are eliminated through a fast rejection algorithm and cross-sectional verification. Polygon entities are generated and their areas are calculated. The method includes the generation of points, lines and polygons and the area calculation steps. The fast rejection algorithm is used to determine overlap and the cross-sectional verification is used to determine intersection.
It effectively solved the problem of abnormal area calculation, improved calculation and traversal efficiency, reduced the operating load, and ensured the accuracy of measurement results.
Smart Images

Figure CN115979202B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of geographic information systems, and more specifically to a GIS-based area measurement method and system. Background Technology
[0002] Geographic Information System (GIS) is a computer technology system for acquiring, processing, displaying, and applying geographic information. It mainly includes data input, data processing, and data display. Currently, traditional area measurement functions primarily rely on simplified area measurement methods provided by various geographic information application providers. However, these methods encounter various problems in complex area measurement scenarios, including: overlapping graphics may result in an area of 0 or even a negative value; similar graphics may yield vastly different results, even showing inverted arrangements, leading to inaccurate measurement results. Summary of the Invention
[0003] The purpose of this invention is to propose a GIS-based area measurement method and system.
[0004] The technical solution for achieving the objective of this invention is: a GIS-based area measurement method, comprising the following steps:
[0005] Step 1: Input map coordinates and obtain the coordinate array of the current area measurement;
[0006] Step 2: Based on the length of the current area measurement coordinate array in Step 1, perform different processing steps. If the current area measurement coordinate array length is 0 or 1, add the input map coordinates to the end of the coordinate array to generate a point entity, and proceed to Step 1. If the current area measurement coordinate array length is 2, add the input map coordinates to the end of the coordinate array to generate a polygon entity, and proceed to Step 4 to calculate the area of the polygon entity. If the current area measurement coordinate array length is greater than 2, proceed to Step 3 to determine whether the coordinate array conforms to the overlap and intersection rules. For coordinate arrays that conform to the rules, add the input map coordinates to generate a polygon entity and calculate the area of the polygon entity.
[0007] Step 3: Combine the input coordinates with the first coordinate in the coordinate array to form the traversal coordinates L1. Combine the first and second coordinates to form the traversed coordinates L2. Use the fast rejection algorithm to verify if L1 and L2 overlap. If there is no overlap, combine the second and third coordinates in the coordinate array to form the traversed coordinates L2 and continue traversing. If there is overlap, perform a cross-intersection check to verify if they intersect. If the cross-intersection check shows intersection, the traversal ends, and the current coordinate array is determined to be inconsistent with the rules. If the cross-intersection check shows non-intersection, combine the second and third coordinates in the coordinate array to form the traversed coordinates L2 and continue traversing. Continue in this manner until all coordinates have been traversed.
[0008] Step 4: Calculate the area of the polygon entity based on the coordinate array.
[0009] Furthermore, in step 2, if the current area measurement coordinate array length is 0, the input map coordinates are added to the end of the coordinate array to generate a point entity; if the current area measurement coordinate array length is 1, the input map coordinates are added to the end of the coordinate array to generate the second point entity of the line.
[0010] Furthermore, in step 3, the coordinates of the traversal coordinate pair L1 are denoted as: [P 11 (x 11 ,y 11 ), P 12 (x 12 ,y 12 The coordinates of the traversed coordinate pair L2 are denoted as: [P] 21 (x 21 ,y 21 ), P 22 (x 22 ,y 22 Using the coordinates of L1 and L2 as diagonals to form a rectangle, the coordinates of the two rectangles are: R1: [P 11 (x 11 ,y 11 ), P 12 (x 12 ,y 11 ), P 13 (x 12 ,y 12 ), P 14 (x 11 ,y 12 R2: [P] 21 (x 21 ,y 21 ), P 22 (x 22 ,y 21 ), P 23 (x 22 ,y22 ), P 24 (x 21 ,y 22 Given that rectangles R1 and R2 can have either overlapping or non-overlapping positions, the fast rejection algorithm determines whether rectangles R1 and R2 overlap. The steps are as follows:
[0011] 1. Set the boundaries of rectangles R1 and R2
[0012] x 11 and x 12 The smaller value is denoted as X1. min The larger value is denoted as X1. max , will y 11 and y 12 The smaller value is denoted as Y1. min The larger value is denoted as Y1. max ;
[0013] x 21 and x 22 The smaller value is denoted as X2. min The larger value is denoted as X2. max , will y 21 and y 22 The smaller value is denoted as Y2. min The larger value is denoted as Y2. max ;
[0014] 2. Compare whether R1 and R2 overlap:
[0015] (1)Judge Y1 min Is it less than Y2? max ;
[0016] (2) Determine X2 max Is it less than X2? min ;
[0017] (3)Judge Y2 min Is it less than Y1? max ;
[0018] (4) Determine X1 max Is it less than X2? min ;
[0019] 3. If all the judgment results of the above (1), (2), (3), and (4) are true, then rectangles R1 and R2 do not overlap, that is, the two line segments must not intersect.
[0020] Furthermore, in step 3, the coordinates of the traversal coordinate pair L1 are denoted as: [P 11 (x 11 ,y 11 ), P 12 (x 12,y 12 The coordinates of the traversed coordinate pair L2 are denoted as: [P] 21 (x 21 ,y 21 ), P 22 (x 22 ,y 22 If L1 and L2 intersect, then the two endpoints P of line segment L2... 21 and P 22 It must be on both sides of line segment L1, and at the same time, the two endpoints P of line segment L1... 11 and P 12 The endpoints must be on either side of line segment L2. To verify this, we need to use the cross product of vectors to find the vector product between the coordinates of the endpoints of line segments L1 and L2.
[0021] V1=(x 21 -x 11 )*(y 12 -y 11 )-(x 12 -x 11 )*(y 21 -y 11 )
[0022] V2=(x 22 -x 11 )*(y 12 -y 11 )-(x 12 -x 11 )*(y 22 -y 11 )
[0023] V3=(x 11 -x 21 )*(y 22 -y 21 )-(x 22 -x 21 )*(y 11 -y 21 )
[0024] V4=(x 12 -x 21 )*(y 22 -y 21 )-(x 22 -x 21 )*(y 12 -y 21 )
[0025] In the above formula, if V1*V2>0 and V3*V4>0, it means that the two line segments intersect; otherwise, the two lines do not intersect.
[0026] Furthermore, in step 4, for the area measurement coordinate array PA: [(x1,y1),(x2,y2),...,(x i ,y i The area A of the area is:
[0027]
[0028] Where n is the length of the PA array, x i Let y be the longitude value of the i-th coordinate in PA. i Let be the latitude value of the i-th coordinate in PA.
[0029] A GIS-based area measurement system, which realizes GIS-based area measurement based on the aforementioned area measurement method.
[0030] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it performs GIS-based area measurement based on the area measurement method described above.
[0031] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs GIS-based area measurement based on the area measurement method described above.
[0032] Compared with the prior art, the significant advantages of this invention are:
[0033] (1) By eliminating input coordinates that do not conform to the rules through cross-sectional verification, the abnormal area calculation in some cases was resolved.
[0034] (2) By rapidly eliminating the computational complexity, the efficiency of traversal is improved, and the operating load is effectively reduced. Attached Figure Description
[0035] Figure 1 This is a flowchart illustrating a GIS-based area measurement method according to the present invention.
[0036] Figure 2 This is a schematic diagram showing a case where rectangles have overlapping parts;
[0037] Figure 3 This is a schematic diagram showing the case where the rectangles have no overlapping parts;
[0038] Figure 4 This is a diagram illustrating the intersection of line segments;
[0039] Figure 5 This is a diagram illustrating the case where line segments do not intersect.
[0040] Figure 6 This is an example image of the first entity whose area was measured.
[0041] Figure 7 This is an example image of the second area measurement entity being input;
[0042] Figure 8 This is an example diagram of generating polygonal entities and calculating their areas;
[0043] Figure 9 This is an example image of input coordinates that do not conform to the rules;
[0044] Figure 10 This is an example image showing input coordinates that conform to the rules. Detailed Implementation
[0045] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0046] A GIS-based area measurement method, the measurement process is as follows: Figure 1 As shown, it includes the following steps:
[0047] Step 1: Input map coordinates via text input, map clicks, or other methods, and simultaneously obtain the coordinate array of the current area measurement.
[0048] Step 2: Based on the length of the current area measurement coordinate array from Step 1, perform different processing steps, as follows:
[0049] 1. If the current area measurement coordinate array length is 0, then the coordinate is added to the end of the coordinate array, and the GIS engine generates a point entity at that coordinate;
[0050] 2. If the current area measurement coordinate array has a length of 1, then the coordinate is added to the end of the coordinate array, and the GIS engine generates the second point entity of the line based on the coordinate array;
[0051] 3. If the current area measurement coordinate array has a length of 2, add the coordinate to the end of the array. The GIS engine generates polygon entities based on the coordinate array and deletes point entities. Calculate the area of the current coordinate array using the area algorithm (see step 5). Simultaneously, define the first coordinate stored in the coordinate array as the "measurement starting point".
[0052] 4. If the length of the current area measurement coordinate array is greater than 2, iterate through the coordinate array (see step 3) and determine whether the current input coordinates conform to the rules based on the results of the coordinate array traversal.
[0053] Step 3: The following content is processed by iterating through the coordinate array:
[0054] 1. Combine the input coordinates with the first coordinate in the coordinate array to form the "traversal coordinates" L1, and traverse the coordinate array. The number of traversals is the length of the coordinate array minus 1. For each traversal, combine the coordinates of the traversal index and the next coordinate to form the "traversed coordinates" L2.
[0055] 2. The "traversed coordinates" L1 and the "traversed coordinates" L2 are subjected to a "fast rejection" algorithm (see step 6) to verify whether L1 and L2 overlap. If there is no overlap, the traversal continues; if there is an overlap, a "cross-intersection check" (see step 7) is performed to verify whether they intersect. If the result of the "cross-intersection check" (see step 7) is intersection, the traversal ends, and the current input coordinates are determined to be inconsistent with the rules; if the result of the "cross-intersection check" (see step 7) is non-intersection, the traversal continues.
[0056] 3. If, after the traversal is complete, there is no case where the results of the "cross-check" between the "traversed coordinates" L1 and the "traversed coordinates" L2 intersect, then the current input coordinates are determined to meet the rules.
[0057] Step 4: If the judgment result obtained in Step 3 is that it does not conform to the rules, no further processing is done on the input coordinates—the coordinate array is not updated, the graphics are not redrawn, and the area is not recalculated; if the judgment result obtained in Step 3 is that it conforms to the rules, the coordinate is added to the end of the coordinate array; the map engine updates the polygon entities according to the new coordinate array and re-renders; the area algorithm (see Step 5) is called to recalculate the area of the current new coordinate array.
[0058] Step 5: The specific details of the area algorithms used in Steps 2 and 4 are as follows:
[0059] For the area measurement coordinate array [(x1,y1),(x2,y2),...,(x i ,y i )], where x i The coordinates are longitude values, y i Here are the latitude values of the coordinates. Its area is:
[0060]
[0061] Step 6: The specific steps of the "fast rejection" algorithm used in Step 3 are as follows:
[0062] 1. Denote the coordinates of the "traversal coordinate pair" L1 as: [P 11 (x 11 ,y 11 ), P 12 (x 12 ,y 12 )], the coordinates of the “traversed coordinate pair” L2 are labeled as: [P 21 (x 21,y 21 ), P 22 (x 22 ,y 22 )).
[0063] Using the coordinates of L1 and L2 as diagonals to form a rectangle, the coordinates of the two rectangles are as follows:
[0064] R1: [P] 11 (x 11 ,y 11 ), P 12 (x 12 ,y 11 ), P 13 (x 12 ,y 12 ), P 14 (x 11 ,y 12 )]
[0065] R2: [P] 21 (x 21 ,y 21 ), P 22 (x 22 ,y 21 ), P 23 (x 22 ,y 22 ), P 24 (x 21 ,y 22 )]
[0066] Then R1 and R2 have two possible positional relationships: overlapping and non-overlapping (e.g. Figure 2 and Figure 3 To determine if rectangles R1 and R2 overlap, the steps are as follows:
[0067] 1. Set the boundaries of rectangles R1 and R2
[0068] x 11 and x 12 The smaller value is denoted as X1. min The larger value is denoted as X1. max , will y 11 and y 12 The smaller value is denoted as Y1. min The larger value is denoted as Y1. max ;
[0069] x 21 and x 22 The smaller value is denoted as X2. min The larger value is denoted as X2. max , will y 21 and y 22 The smaller value is denoted as Y2.min The larger value is denoted as Y2. max .
[0070] 2. Compare whether R1 and R2 overlap:
[0071] (1)Judge Y1 min Is it less than Y2? max ;
[0072] (2) Determine X2 max Is it less than X2? min ;
[0073] (3)Judge Y2 min Is it less than Y1? max ;
[0074] (4) Determine X1 max Is it less than X2? min ;
[0075] 3. If all the judgment results of the above (1), (2), (3), and (4) are true, then rectangles R1 and R2 do not overlap, that is, the two line segments must not intersect.
[0076] Step 7: The specific details of the "cross-cut verification" algorithm in Step 3 are as follows:
[0077] 1. Define the coordinates of the "traversal coordinate pair" L1 as: [P 11 (x 11 ,y 11 ), P 12 (x 12 ,y 12 )], the coordinates of the “traversed coordinate pair” L2 are labeled as: [P 21 (x 21 ,y 21 ), P 22 (x 22 ,y 22 If L1 and L2 intersect, then the two endpoints P of line segment L2... 21 and P 22 It must be on both sides of line segment L1, and at the same time, the two endpoints P of line segment L1... 11 and P 12 It must be on the left and right sides of line segment L2, as follows: Figure 4 and Figure 5 .
[0078] To address this, we need to use the cross product to calculate the vector product between the coordinates of the endpoints of line segments L1 and L2:
[0079] V1=(x 21 -x 11 )*(y 12 -y11 )-(x 12 -x 11 )*(y 21 -y 11 )
[0080] V2=(x 22 -x 11 )*(y 12 -y 11 )-(x 12 -x 11 )*(y 22 -y 11 )
[0081] V3=(x 11 -x 21 )*(y 22 -y 21 )-(x 22 -x 21 )*(y 11 -y 21 )
[0082] V4=(x 12 -x 21 )*(y 22 -y 21 )-(x 22 -x 21 )*(y 12 -y 21 )
[0083] In the above formula, if V1*V2>0 and V3*V4>0, it means that the two line segments intersect; otherwise, the two lines do not intersect.
[0084] Example
[0085] To verify the effectiveness of the present invention, the following experiment was conducted.
[0086] A GIS-based area measurement method specifically includes the following steps:
[0087] Step 1: Input map coordinates via text input, map clicks, or other methods, and simultaneously obtain the coordinate array of the current area measurement.
[0088] Step 2: Based on the length of the current area measurement coordinate array from Step 1, perform different processing steps, as follows:
[0089] 1. If the current area measurement coordinate array length is 0, then the coordinate is added to the end of the coordinate array, and the GIS engine generates a point entity at that coordinate, such as... Figure 6 ;
[0090] 2. If the current area measurement coordinate array has a length of 1, then the coordinate is added to the end of the coordinate array. The GIS engine generates a second point entity based on the coordinate array, such as... Figure 7 ;
[0091] 3. If the current area measurement coordinate array has a length of 2, the coordinate is added to the end of the array. The GIS engine generates polygon entities based on the coordinate array and deletes point entities. The area of the current coordinate array is calculated using the area algorithm (see step 5). The first coordinate stored in the coordinate array is defined as the "measurement starting point," such as... Figure 8 ;
[0092] 4. If the length of the current area measurement coordinate array is greater than 2, traverse the coordinate array (see step 3) and determine whether the current input coordinates conform to the rules by the result of traversing the coordinate array.
[0093] Step 3: Iterate through the coordinate array and determine if the current input coordinates conform to the rules. If the result is that they do not conform to the rules, no further processing is done on the input coordinates—the coordinate array is not updated, the graphics are not redrawn, and the area is not recalculated. If the result is that they conform to the rules, the coordinates are added to the end of the coordinate array; the map engine updates the polygon entities based on the new coordinate array and re-renders; the area algorithm is called to recalculate the area of the current new coordinate array. Figure 9 Figure 10 .
[0094] 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.
[0095] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these modifications and improvements all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A GIS-based area measurement method, characterized in that, Includes the following steps: Step 1: Obtain the map input coordinates P, and simultaneously obtain the coordinate array PA of the current area measurement. PA is initially an empty array; after inputting coordinates, PA becomes [P1, P2, P2, ..., P]. n ]; Step 2: Based on the length of the current area measurement coordinate array PA in Step 1, perform different processing steps. If the length of the current area measurement coordinate array PA is 0 or 1, add the input map coordinate P to the end of the coordinate array PA, generate a point entity on the map, and proceed to Step 1. If the length of the current area measurement coordinate array PA is 2, add the input map coordinate to the end of the coordinate array PA, generate a polygon entity, and proceed to Step 4 to calculate the area of the polygon entity. If the length of the current area measurement coordinate array PA is greater than 2, proceed to Step 3 to determine whether the input coordinate P and the coordinate array PA meet the overlap and intersection rules. If they do, add the input coordinate P to the end of the coordinate array PA, generate a polygon entity, and calculate the area of the polygon entity. Step 3: Combine the input coordinate P with the first coordinate P1 of the coordinate array PA to form a traversal coordinate pair L1. Traverse the coordinate array PA for one traversal of the length of the coordinate array PA minus 1. For each traversal, combine the coordinate of the traversal index with the next coordinate to form a traversed coordinate pair L2. Use a fast rejection algorithm to verify whether L1 and L2 overlap. If there is no overlap, continue traversing. If there is an overlap, perform a cross-intersection check to verify whether they intersect. If the cross-intersection check shows intersection, the traversal ends, and the current input coordinate P is determined to be non-compliant. If the cross-intersection check shows non-intersection, continue traversing. If no intersection is found after the traversal ends, the current input coordinate P is determined to be compliant. Step 4: Calculate the area of the polygon entity based on the coordinate array.
2. The GIS-based area measurement method according to claim 1, characterized in that, In step 2, if the current area measurement coordinate array length is 0, the input map coordinate P is added to the end of the coordinate array PA, and the map generates a point entity; if the current area measurement coordinate array length is 1, the input map coordinate P is added to the end of the coordinate array PA, and the map generates a second point entity.
3. The GIS-based area measurement method according to claim 1, characterized in that, In step 3, the coordinates of the "traversal coordinate pair" L1 are marked as: [P 11 (x 11 ,y 11 ), P 12 (x 12 ,y 12 )], the coordinates of the "traversed coordinate pair" L2 are labeled as: [P 21 (x 21 ,y 21 ), P 22 (x 22 ,y 22 If L1 and L2 intersect, then the two endpoints P of line segment L2... 21 and P 22 It must be on both sides of line segment L1, and at the same time, the two endpoints P of line segment L1... 11 and P 12 The endpoints must be on either side of line segment L2. To verify this, we need to use the cross product of vectors to find the vector product between the coordinates of the endpoints of line segments L1 and L2. ; ; ; ; In the above formula, if and If the two lines intersect, then they do not; otherwise, they do not intersect.
4. The GIS-based area measurement method according to claim 1, characterized in that, In step 4, for the area measurement coordinate array PA: Its area A is: ; Where n is the length of the PA array. Let be the longitude value of the i-th coordinate in PA. Let be the latitude value of the i-th coordinate in PA.
5. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it performs GIS-based area measurement based on the area measurement method according to any one of claims 1-4.
6. A computer-readable storage medium having a computer program stored thereon, wherein when executed by a processor, the computer program implements GIS-based area measurement based on the area measurement method according to any one of claims 1-4.
Citation Information
Patent Citations
Method for locating administrative division based on longitude and latitude
CN103377585A
Polygon set union calculating method based on multistage grids
CN103440611A
