Auto-processing method for AutoCAD topographic map draft base map
By using OpenCV and the Douglas-Puk algorithm to automatically correct and locate the base map for topographic map redrawing, the problem of cumbersome operation caused by paper deformation in topographic map redrawing is solved, and the electronic base map for redrawing is efficiently overlaid and accurately positioned on AutoCAD map sheets.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JIANGSU YITU GEOGRAPHIC INFORMATION TECH CO LTD
- Filing Date
- 2023-04-04
- Publication Date
- 2026-04-21
AI Technical Summary
In the process of topographic map adjustment, the distortion of printed drawings makes correction and positioning operations cumbersome, making it difficult to efficiently and accurately overlay the electronic base map with the AutoCAD drawing sheet.
By using OpenCV contour recognition and the Douglas-Puk algorithm, the system automatically corrects the base map image file, identifies coordinates, and calculates the insertion position and magnification ratio, thus achieving efficient positioning of the electronic base map on the AutoCAD drawing sheet.
It enables efficient correction and positioning of the base map on the AutoCAD drawing sheet, improves work efficiency, and ensures the accuracy of subsequent element additions.
Smart Images

Figure CN116152377B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of geographic information technology; and more particularly to a method for supplementing elements based on new elements obtained from topographic map adjustments. Background Technology
[0002] After acquiring the basic topographic map, due to the limitations of the original acquisition, it often fails to accurately represent some basic ground features (i.e., basic elements, such as power facilities, municipal fixed structures, and agricultural irrigation facilities). This results in insufficient accuracy in the final topographic map, making it difficult to meet the needs of the general public. Therefore, after acquiring the basic topographic map, it is necessary to manually adjust and redraw it, supplementing and annotating some basic ground features to form a base map for topographic map adjustment. This process involves the following steps: printing the basic topographic map onto paper - manually adjusting the paper map on-site - scanning the adjusted base map into an electronic version (JPG, PDF, etc.) - entering the electronic base map into the computer and matching it with the original basic topographic map.
[0003] The base map for topographic mapping is a sketch that clearly depicts the actual features of the ground. Field surveys are the primary basis for editing and producing the final topographic map; the base map is the printed sketch after topographic data collection (e.g.,...). Figure 2 After obtaining the topographic map base map, a repair operation is required, which involves overlaying and comparing the topographic map base map with the AutoCAD topographic map, and then repairing and supplementing the elements in the AutoCAD topographic map.
[0004] In existing techniques, the printed drawings are often distorted and lack coordinate information for the inner outlines. Therefore, users use drawing correction software such as GloableMap to correct these distortions. Figure 2 The inner map outline is first manually matched to the correct coordinates, and the corresponding corrected file is generated and the coordinate parameters are saved. Finally, the operator imports the corrected data into AutoCAD, and then makes further corrections by overlaying the topographic map data on top of the base map.
[0005] In the above process, the "correction and positioning" step alone has the drawbacks of being cumbersome and difficult to operate. Summary of the Invention
[0006] To address the above-mentioned technical problems, this invention provides an automatic processing method for AutoCAD topographic map base maps that can efficiently overlay electronic versions of the base map onto topographic maps, achieving efficient correction and positioning.
[0007] The technical solution of this invention is: based on the original topographic map, the image file of the adjusted base map is corrected and positioned on the AutoCAD map sheet.
[0008] Includes the following steps:
[0009] S1. Correction: Correct the base map image file.
[0010] S2. Recognition, coordinate recognition,
[0011] S3. Positioning: Calculate the insertion position and magnification ratio of the base map image file in CAD to achieve positioning;
[0012] Step S1 specifically involves:
[0013] S1-1. Obtain the set I of all closed outer contours in the base map image file using OpenCV contour recognition;
[0014] S1-2. Calculate the maximum outer contour e from the closed outer contour set I;
[0015] S1-3. Using the Douglas-Puk algorithm, with the precision set to 0.1, fit the maximum outer contour e to obtain the point set P;
[0016] S1-4. Determine whether the number of points in point set P is 4.
[0017] If so, proceed to the next step;
[0018] If not, then the process ends;
[0019] S1-5. Calculate the coordinates of the top left corner minp and the bottom right corner maxp of the minimum envelope rectangle r of point set P;
[0020] S1-6. Calculate the maximum range s of the corrected graphic using the coordinates minp of the upper left corner, maxp of the lower right corner, and the ratio, and save its four point coordinates Q1~Q4;
[0021] S1-7. Using point set P and the coordinates of four points Q1~Q4 as projection transformation parameters, project and transform the area in the map into a temporary image img2.
[0022] At the same time, return the upper left pixel values of the region in the original image, upper_left_x and upper_left_y;
[0023] Then, by obtaining the line width in the left-center region of img2, and simultaneously covering the area of the original image with img2, the corrected image is obtained.
[0024] Step S2 specifically involves:
[0025] Extract the middle third of the area above the temporary image img2 in the original image, extract the text using OCR, and check if the extracted text contains text information in the format XXX.XX-XXX.XX.
[0026] If so, convert it to the coordinates of the lower left corner of the inner map frame (location_x, location_y).
[0027] Otherwise, the process ends.
[0028] Step S3 specifically involves:
[0029] S3-1. Calculate the coordinates of the lower left corner of the covered image, as well as its length and width, and the magnification ratio in AutoCAD, using the coordinates of the lower left corner of img2 and the line width of the outer outline. These are denoted as image_x, image_y, and image_scale, respectively.
[0030] The specific calculation process is as follows:
[0031] 1) Calculate the position of the top-left pixel and the length and width of the image frame based on the width:
[0032] ①.upper_left_x=upper_left_x+(width / 2+1),
[0033] upper_left_y=upper_left_y+(width / 2+1);
[0034] ②.boundary_width=boundary_width–width,
[0035] boundary_height=boundary_height–width;
[0036] 2) Calculate the distance from the pixel at the bottom left corner of the outer frame to the bottom left corner of the image along the X and Y axes:
[0037] ①. delta_x = upper_left_x,
[0038] ②.delta_y=shape_y-upper_left_y-boundary_height;
[0039] 3) Calculate the coordinates of the AutoCAD image insertion:
[0040] ①.image_x=location_x-delta_x*K / boundary_width–C,
[0041] ②.image_y=location_y-delta_y*K / boundary_height–C;
[0042] Where C represents the distance from the outer map frame to the inner map frame based on a 500 scale, and K represents the width of the outer map frame.
[0043] 4) Calculate the image magnification ratio:
[0044] Image_scale=shape_x*K / boundary_width,
[0045] S3-2. Insert an image and set its coordinates and zoom level to image_x, image_y, image_scale.
[0046] Furthermore, before proceeding to step S1, the paper drawing generated by the sketch is scanned to obtain the base image.
[0047] Further, the base image is converted into a grayscale image.
[0048] Furthermore, in S1-1, the image resolution is denoted as shape_x and shape_y.
[0049] This invention addresses the drawbacks of existing technologies that require manual processing and multiple steps for drawing base maps, and achieves a more efficient and efficient process for drawing base maps. Figure 1 This invention significantly improves work efficiency through key correction and positioning. First, it uses contour recognition to determine the boundaries of the base map; then, it uses relevant algorithms to obtain the minimum envelope rectangle, thereby determining the maximum range of the corrected image; subsequently, image correction is performed to "restore" the distorted base map to be as close as possible to the original base topographic map, laying a good foundation for subsequent overlay and synthesis. Second, considering the original information in the base map, it identifies the basic coordinate data to determine the insertion position of the base map. Then, based on calculations, it determines the corrected positioning position and magnification ratio, achieving accurate overlay of the corrected image onto the AutoCAD map. This invention automatically realizes the "overlay" of the electronic base map and the AutoCAD map, providing a more accurate basis for subsequent element addition and supplementation labeling. Attached Figure Description
[0050] Figure 1 This is a flowchart of the process of the present invention.
[0051] Figure 2 This is an image file generated by adjusting the base map in this invention.
[0052] Figure 3 This is a schematic diagram illustrating how the present invention obtains the set of all closed outer contours I in an image file.
[0053] Figure 4 This is a schematic diagram illustrating how the present invention obtains the point set P within the maximum outer contour e.
[0054] Figure 5 This is a schematic diagram illustrating the formation of the minimum envelope rectangle e according to the present invention.
[0055] Figure 6 This is a schematic diagram showing the maximum range s of the corrected pattern formed by the present invention.
[0056] Figure 7 This is the temporary image image img2 obtained after projection transformation according to the present invention.
[0057] Figure 8 This is a diagram showing the temporary image (img2) overlaid on the original image.
[0058] Figure 9 This is a schematic diagram of the top middle third of the original image.
[0059] Figure 10 The coordinates and magnification ratio of the inserted image obtained by magnification according to the present invention.
[0060] Figure 11 It is an AutoCAD drawing sheet. Detailed Implementation
[0061] The following is in conjunction with the appendix Figure 1-11 The entire implementation process of this invention will be further explained. The overall engineering flow of this invention is as follows: Figure 1 As shown.
[0062] An automatic processing method for adjusting base maps based on AutoCAD topographic maps corrects the image files of the base maps and positions them on the AutoCAD map sheet, using the original topographic map as a reference.
[0063] Includes the following steps:
[0064] S1. Correction: Correct the base image file of the mapping. Of course, the paper map formed by mapping must be scanned first to obtain the electronic base image. Those skilled in the art can set it to formats such as jpg, png, etc. according to their usage habits.
[0065] Convert the electronic background image to a grayscale image, such as Figure 2 This facilitates subsequent processing;
[0066] After a series of operations such as printing, external investigation, hand-drawn additions, and scanning, the actual electronic map obtained will have a certain degree of distortion in its map frame. If this is not processed, it will lead to inaccurate positioning during subsequent additions and supplements, resulting in inaccurate location points of the added elements.
[0067] S2. Identification, coordinate identification; Since the paper maps carried by the field investigators all have coordinate data on them, the coordinates must be identified in order to obtain the positioning reference point in the subsequent positioning process.
[0068] S3. Positioning: Calculate the insertion position and magnification ratio of the base map image file in CAD to achieve positioning;
[0069] Step S1 is as follows:
[0070] S1-1. Obtain the set I of all closed outer contours in the base map image file using OpenCV contour recognition; in this step, Figure 3 The solid-line box, top text, bottom text, and left text in the text will all be recognized as closed outer contours, i.e. Figure 3 Medium I-1, I-2, I-3, I-4;
[0071] S1-2. Calculate the maximum outer contour e from the closed outer contour set I; that is... Figure 3 Middle quadrilateral frame;
[0072] S1-3. Using the Douglas-Pock algorithm with a precision of 0.1, fit the maximum outer contour e to obtain the point set P; after setting the precision in this step, use the Douglas-Pock algorithm to obtain the point set P (i.e., the intersection points of the rectangular boxes) in the maximum outer contour e. Figure 3 (Displayed as the four vertices of a rectangular frame), such as Figure 4 In the cases P1, P2, P3, and P4, the maximum outer contour e obtained at this point is not a rectangle, either theoretically or practically, so it needs to be corrected.
[0073] S1-4. Determine whether the number of points in point set P is 4.
[0074] If so, proceed to the next step;
[0075] If not, the process ends; the procedure ends because no outer profile was found.
[0076] S1-5. Calculate the minimum envelope rectangle r of point set P (e.g., ... Figure 5 The coordinates of the top left corner (minp) and the bottom right corner (maxp) are given.
[0077] S1-6. Calculate the maximum range s of the corrected graph (the range is a rectangle, e.g., minp, maxp, and ratio) using the coordinates of the upper left corner and the lower right corner, as well as the ratio. Figure 6 Save the coordinates of its four points Q1~Q4; that is, reserve the "coverage area" of the corrected image.
[0078] Its coordinates are in counter-clockwise order of {[0,0],[0,height],[width,height],[width,0]}, where the height is min(maxp.x-minp.x,maxp.y-minp.y) and the width is height * ratio. Let the height be boundary_height and the width be boundary_width.
[0079] S1-7. Using the point set P and the coordinates of four points Q1~Q4 as projection transformation parameters, the area in the map is projected and transformed into a temporary image img2, such as... Figure 7 ;
[0080] It also returns the upper left pixels (upper_left_x, upper_left_y) of that region in the original image. This is to prepare for subsequent calculations.
[0081] It also obtains the line width by measuring the left-center region of img2, and simultaneously covers the original image (i.e., the electronic base image) with img2. Figure 6 (area); corrected image obtained;
[0082] Soon Figure 5 For map areas that are not rectangular, a projection transformation is performed, "stretching" them into a quadrilateral shape. Figure 6 Temporary images of roughly equal size from Q1 to Q4.
[0083] Step S2 specifically involves:
[0084] Extract the middle third of the area above the temporary image img2 in the original image. Figure 8 , 9 The function extracts text using OCR and checks whether the extracted text contains text information in the format XXX.XX-XXX.XX.
[0085] If so, convert it to the coordinates of the lower left corner of the inner map frame (location_x, location_y).
[0086] Otherwise, the process ends.
[0087] Step S3 specifically involves:
[0088] S3-1. Using the coordinates of the bottom left corner of img2, determine the line width of the outer outline ( Figure 7 The coordinates of the lower left corner, length, and width of the covered image (from the left side line) and the magnification ratio in AutoCAD are calculated and denoted as image_x, image_y, and image_scale, respectively.
[0089] Since the width (X-axis direction) of the electronic base map is set to "1" by AutoCAD when it is inserted into the AutoCAD drawing sheet, this step not only needs to achieve precise positioning, but also needs to "enlarge" it; so that the electronic base map "covers" the reference point of the AutoCAD drawing sheet, that is, to accurately position and cover the corrected image onto the AutoCAD drawing sheet;
[0090] The specific calculation process is as follows:
[0091] (1) Calculate the position of the pixel at the top left corner and the length and width of the image frame based on the width:
[0092] ①.upper_left_x=upper_left_x+(width / 2+1),
[0093] upper_left_y=upper_left_y+(width / 2+1);
[0094] ②.boundary_width=boundary_width-width,
[0095] boundary_height=boundary_height-width
[0096] (2) Calculate the distance from the pixel at the lower left corner of the outer outline to the lower left corner of the image along the X and Y axes:
[0097] ①.delta_x = upper_left_x;
[0098] ②.delta_y=shape_y-upper_left_y-boundary_height.
[0099] (3) Calculate the coordinates of the AutoCAD image insertion:
[0100] ①.image_x=location_x-delta_x*K / boundary_width-C;
[0101] ②.image_y=location_y-delta_y*K / boundary_height-C.
[0102] Where C represents the distance between the outer and inner map frames based on a scale of 500 (C = scale / 500 * 12), and K represents the width of the outer map frame (K = scale / 500 * 524). For example, when the scale is 500, the distances are 12 and 524 respectively.
[0103] (4) Calculate the image magnification ratio: The default size of the imported image in AutoCAD is 1 (that is, the length in the X-axis direction is 1), but if it is to overlap with the original vector image, the size of the image needs to be magnified to the size of the image frame;
[0104] Image_scale=shape_x*K / boundary_width
[0105] S3-2. Insert an image and set its coordinates and zoom level to image_x, image_y, image_scale. (e.g.) Figure 10 )
[0106] In step S1-1, the image resolution is denoted as shape_x and shape_y. Recording the resolution of the electronic base map image is for subsequent calculations.
[0107] This invention is not limited to the above embodiments. Based on the technical solutions disclosed in this invention, those skilled in the art can make some substitutions and modifications to some of the technical features without creative effort, and all such substitutions and modifications are within the protection scope of this invention.
Claims
1. An automatic processing method for drawing base maps based on AutoCAD topographic maps, using the original topographic map as a reference, characterized in that: The image file of the base map is corrected and positioned on the AutoCAD drawing sheet. Includes the following steps: S1. Correction: Correct the base map image file. S2. Recognition, coordinate recognition, S3. Positioning: Calculate the insertion position and magnification ratio of the base map image file in CAD to achieve positioning; Step S1 specifically involves: S1-1. Obtain the set I of all closed outer contours in the base map image file using OpenCV contour recognition; S1-2. Calculate the maximum outer contour e from the closed outer contour set I; S1-3. Using the Douglas-Puk algorithm, with the precision set to 0.1, fit the maximum outer contour e to obtain the point set P; S1-4. Determine whether the number of points in point set P is 4. If so, proceed to the next step; If not, then the process ends; S1-5. Calculate the coordinates of the top left corner minp and the bottom right corner maxp of the minimum envelope rectangle r of point set P; S1-6. Calculate the maximum range s of the corrected graphic using the coordinates minp of the upper left corner, maxp of the lower right corner, and the ratio, and save its four point coordinates Q1~Q4; S1-7. Using point set P and the coordinates of four points Q1~Q4 as projection transformation parameters, the area in the map is projected and transformed into a temporary image img2. At the same time, return the upper left pixel values of the region in the original image, upper_left_x and upper_left_y; Then, by obtaining the line width in the left-center region of img2, and simultaneously covering the area of the original image with img2, the corrected image is obtained; Step S2 specifically involves: Extract the middle third of the area above the temporary image img2 in the original image, extract the text using OCR, and check if the extracted text contains text information in the format XXX.XX-XXX.XX. If so, convert it to the coordinates of the lower left corner of the inner map frame (location_x, location_y). If not, then the process ends; Step S3 specifically involves: S3-1. Calculate the coordinates of the lower left corner of the covered image, as well as its length and width, and the magnification ratio in AutoCAD, using the coordinates of the lower left corner of img2 and the line width of the outer outline. These are denoted as image_x, image_y, and image_scale, respectively. The specific calculation process is as follows: 1) Calculate the position of the top-left pixel (upper_left_x, upper_left_y) and the length and width of the image frame (boundary_width, boundary_height) based on the width. ①.upper_left_x=upper_left_x+(width / 2+1), upper_left_y=upper_left_y+(width / 2+1); ②.boundary_width=boundary_width–width, boundary_height=boundary_height–width; 2) Calculate the distances delta_x and delta_y from the pixel at the bottom left corner of the outer frame to the bottom left corner of the image along the X and Y axes. ①. delta_x = upper_left_x, ②.delta_y=shape_y-upper_left_y-boundary_height; 3) Calculate the coordinates of the AutoCAD image insertion: ①.image_x=location_x-delta_x*K / boundary_width–C, ②.image_y=location_y-delta_y*K / boundary_height–C; Where C represents the distance from the outer map frame to the inner map frame based on a 500 scale, and K represents the width of the outer map frame. 4) Calculate the image magnification ratio: image_scale=shape_x*K / boundary_width, shape_x and shape_y are the image resolutions. S3-2. Insert an image and set its coordinates and zoom level to image_x, image_y, image_scale.
2. The automatic processing method for drawing base maps based on AutoCAD topographic maps according to claim 1, characterized in that, Before proceeding to step S1, the paper drawing created by the sketch is scanned to obtain the base image.
3. The automatic processing method for drawing base maps based on AutoCAD topographic maps according to claim 2, characterized in that, Convert the base image to a grayscale image.
Citation Information
Patent Citations
Method for drawing digital line scribing topographic map based on image map
CN110246203A
Apparatus, method and program for data processing
JP2005310044A