A GIS map generation method and system
Through vectorization algorithm and affine transformation technology, GIS diagrams are automatically generated, which solves the problem of low efficiency in vectorized land planning maps in the existing technology, and improves the stability and reliability of computer automation operations and results.
Patent Information
- Application Number
- CN202211237494.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-10
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2042-10-10
AI Technical Summary
In the prior art, the acquisition efficiency of vectorized land planning maps is low, requiring a lot of human resources and time, resulting in delayed design work progress and quality compression.
A GIS graph generation method is adopted, including obtaining color block diagrams, determining the number of colors according to the area map range and discrete them, converting them into binary images, using vectorization algorithm to obtain vector diagrams, identifying black blocks and calculating the average perimeter area, Corrosion and filtering, re-producing color, and finally registration is performed through an affine transformation algorithm.
The automatic operation of vectorized land planning maps is realized, which reduces human resource investment, improves the stability and reliability of results, simplifies the design process, and improves the computing speed.
Smart Images

Figure CN115690257B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a method and system for generating a GIS map, and belongs to the field of geographic information data processing. Background Art
[0002] At present, the method of obtaining vectorized land use planning maps is usually to arrange designers to use the grid land use planning map as the base map and draw it manually in the computer-aided design software. This method will consume a lot of human resources and time resources, delay the progress of design work, and reduce the quality of design solutions. Summary of the invention
[0003] A brief summary of one or more aspects is given below to provide a basic understanding of these aspects. This summary is not an exhaustive overview of all conceived aspects, and is neither intended to identify the key or critical elements of all aspects nor to define the scope of any or all aspects. Its only purpose is to give some concepts of one or more aspects in a simplified form as a prelude to a more detailed description that will be given later.
[0004] The main purpose of the present invention is to solve the problem in the prior art that drawing vector color block diagrams is inefficient and time-consuming, and to provide a method and system for generating GIS diagrams.
[0005] To solve the above problems, the solution of the present invention is:
[0006] A method for generating a GIS map, comprising:
[0007] Step 1, obtain the color block image;
[0008] Step 2, determining the number of colors according to the range of the zoning map and discretizing the image colors of the color block map according to the number of colors;
[0009] Step 3, converting the discretized image into a binary image, and using a vectorization algorithm to obtain a vector map of the corresponding color block;
[0010] Step 4, identify the black vector map and calculate the average perimeter area and other indicators of each color block;
[0011] Step 5, corroding and filtering the black corresponding vector map according to the average perimeter area and other indicators obtained in step 4, extracting the real black block, and recoloring the binary image according to the color value list;
[0012] Step 6: Use an affine transformation algorithm to align the re-colored vectorized color block image.
[0013] Preferably, in the above-mentioned method for generating a GIS map, the color block map in step 1 is an urban land planning map in PNG format.
[0014] Preferably, in the above-mentioned method for generating a GIS map, step 2 specifically includes the following sub-steps:
[0015] Step 201, scaling the input image according to actual needs to adjust the image to the most appropriate size;
[0016] Step 202, quantizing the color types contained in the image to determine the number of color types contained in the original raster image;
[0017] Step 203 , by comparing the similarity of each color, the number of colors in the image is reduced to a specified value, and a list of color values is obtained from the quantized image.
[0018] Preferably, in the above-mentioned method for generating a GIS map, step 5 specifically includes the following sub-steps:
[0019] Step 501, calculating the average perimeter, area-to-perimeter ratio, and area-to-perimeter square ratio of color blocks in non-black areas, eliminating colors with an average area-to-perimeter ratio less than a preset value and an average perimeter greater than a preset value, and calculating the average color block perimeter and area-to-perimeter ratio of the remaining colors as a discrimination index for normal planning color blocks;
[0020] Step 502, calculate the average color block area perimeter ratio r of the black area, and shrink the color block inward by a constant multiple of r.
[0021] Preferably, in the above-mentioned method for generating a GIS map, in step 5, the color of the color block before vectorization in step 2 is reassigned to the corresponding vector color block.
[0022] Preferably, in the above-mentioned method for generating a GIS map, in step 6, several points are selected on the map, the actual longitude and latitude coordinates of the selected points are confirmed, and the color block map is adjusted to the position required by the designer through affine transformation calculation.
[0023] A GIS map generating device, comprising:
[0024] A color block acquisition module is used to acquire a color block image;
[0025] A discretization processing module determines the number of colors according to the range of the zoning map and discretizes the image colors of the color block map according to the number of colors;
[0026] The vector graphics processing module converts the discretized image into a binary image and uses the vectorization algorithm to obtain the vector graphics of the corresponding color blocks;
[0027] Vector map calculation module, which identifies black vector maps and calculates indicators such as the average perimeter area of each color block;
[0028] The vector image coloring module erodes and filters the black corresponding vector image according to the average perimeter area and other indicators, extracts the real black blocks, and recolors the binary image according to the color value list;
[0029] The image registration module uses an affine transformation algorithm to register the re-colored vectorized color block image.
[0030] Preferably, in the above-mentioned GIS map generating device, the color block map in the color block acquisition module is an urban land planning map in PNG format.
[0031] Preferably, in the above-mentioned device for generating a GIS map, the discretization processing module performs the following steps:
[0032] Step 201, scaling the input image according to actual needs to adjust the image to the most appropriate size;
[0033] Step 202, quantizing the color types contained in the image to determine the number of color types contained in the original raster image;
[0034] Step 203 , by comparing the similarity of each color, the number of colors in the image is reduced to a specified value, and a list of color values is obtained from the quantized image.
[0035] Preferably, in the above-mentioned GIS map generation device, the vector map coloring module performs the following sub-steps:
[0036] Step 501, calculating the average perimeter, area-to-perimeter ratio, and area-to-perimeter square ratio of color blocks in non-black areas, eliminating colors with an average area-to-perimeter ratio less than a preset value and an average perimeter greater than a preset value, and calculating the average color block perimeter and area-to-perimeter ratio of the remaining colors as a discrimination index for normal planning color blocks;
[0037] Step 502, calculate the average color block area perimeter ratio r of the black area, and shrink the color block inward by a constant multiple of r.
[0038] Therefore, compared with the prior art, the advantages of the present invention are:
[0039] (1) A vectorization algorithm was used to vectorize the land use planning color block map in PNG format, realizing computer automation operation and freeing up human resources from traditional CAD tracing and drawing work;
[0040] (2) The potrace algorithm is used to import the binarized raster image into the calculation to obtain the vectorized image. This method uses the technical path of first binarization and then vectorization calculation and finally re-assigning colors, which reduces the short-term information processing capacity of the hardware system and improves the stability and reliability of the results.
[0041] (3) A registration algorithm based on affine transformation is used to adjust the vectorized image to the spatial position required by the designer. This method has the advantages of simple and reliable algorithm and high computing speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The accompanying drawings, which are incorporated herein and form a part of the specification, illustrate embodiments of the present invention and, together with the description, further serve to explain the principles of the invention and to enable one skilled in the art to make and use the present disclosure.
[0043] Figure 1 A schematic diagram of a method flow in an embodiment of the present invention is illustrated;
[0044] Figure 2 A schematic diagram of a Bezier curve in an embodiment of the present invention is illustrated;
[0045] Figure 3 A schematic diagram of affine transformation in an embodiment of the present invention is illustrated;
[0046] Embodiments of the present invention will be described with reference to the accompanying drawings. DETAILED DESCRIPTION
[0047] Example
[0048] This embodiment first provides a method for generating a GIS map, including:
[0049] S1. Obtain a land color block map in PNG format and import it into the algorithm; wherein, the land color block map in PNG format can be an urban land planning map, and the image file should be placed in the corresponding position in advance according to the code.
[0050] S2. Determine the number of colors according to the range of the zoning map and discretize the image colors according to the number of colors; it includes the following sub-steps:
[0051] (1) Scale the input image according to actual needs and adjust the image to the most appropriate size;
[0052] (2) The quantize function can quantify the color types contained in the image and confirm the number of color types contained in the original raster image. This method uses this function to count the color types contained in the image to be processed;
[0053] (3) The pngquant function can compare the similarity of each color and normalize the colors with similar RGB values in the image, thereby reducing the number of color types. This method uses this function to unify the colors that are difficult for the human eye to distinguish and are relatively close, and uses simple code to count the RGB values of the image after color value normalization into a list of color values for subsequent work.
[0054] S3. Convert the image into a binary image, and use the vectorization algorithm to obtain a vector map of the corresponding color block; the specific operation of this step is to change the grayscale values of all color blocks in the image to 0 or 255. Then call the potrace vectorization algorithm to calculate the binary raster image to form a vector map.
[0055] Image binarization can be the simplest method of image segmentation. Binarization can convert a grayscale image into a binary image. Binarization is achieved by setting the grayscale of pixels greater than a certain critical grayscale value to the grayscale maximum value and the grayscale of pixels less than this value to the grayscale minimum value.
[0056] The specific calculation method is expressed by the following formula:
[0057]
[0058] The same fixed threshold is used uniformly for all pixels in the input image. Pixels greater than the threshold are taken as 255, and those less than the threshold are taken as 0.
[0059] The principle of the potrace algorithm can be divided into the following four steps:
[0060] (1) The bitmap is decomposed into a series of paths between black and white areas; a binary image is placed in a coordinate system, and the coordinate values of the pixel corners are integer values. Points with integer coordinates are the intersection points of 4 pixels. If the colors of the 4 pixels are not exactly the same, the point is called a vertex. The path is composed of a sequence of vertices {V0, ..., Vn}. If V0 = Vn, the path is called a closed path. If the Euclidean distance between two vertices is 1, the two points are called an edge. If the left side of the edge is a black pixel and the right side is a white pixel, the edge is positive. Whenever a closed path is formed, the black pixels inside the path are replaced with white pixels until the entire image is white pixels. At this point, all paths have been found.
[0061] (2) Each path is fitted by an optimal polygon; because the previous step is to find the path along the edge of the pixel, the path at this time is a polygon.
[0062] (3) Each polygon is transformed into a smooth contour line; here, the synthesized curve is generally optimized by adding continuous Bezier curve segments. The most original mathematical formula based on the Bezier curve is the Bernstein polynomial. The Bernstein polynomial can be used to prove that all continuous functions on the interval [a, b] can be approximated by polynomials, and the convergence is very strong, that is, uniform convergence.
[0063] The specific operation method is: select three points A, B, and C on different lines in the plane and connect them with line segments in sequence. Determine points D and E on AB and BC respectively, so that AD / AB=BE / BC holds. Connect DE and find a point F on DE such that DF / DE=AD / AB=BE / BC. Let the selected point D move from the starting point A to the end point B on the first line segment, find all the points F, and connect them. You will get a very smooth curve, which is the Bezier curve (such as Figure 2 shown).
[0064] (4) The output is adjusted to the required format.
[0065] Step 4, identify the black vector map and calculate the average perimeter area and other indicators of each color block;
[0066] Step 5: Corrode and filter the vector map corresponding to black according to the calculated index, extract the real black block, and recolor the binary image according to the color value list; perform corrosion and filtering operations on the identified vector map, and then write the vector map corresponding to the color into a geojson file named by the color value to obtain a vectorized image with the original color block color. In this step, the vectorized image needs to be post-processed, including:
[0067] (1) Calculate the average perimeter, area-to-perimeter ratio, and area-to-perimeter square ratio of color blocks in non-black areas, and eliminate colors with an average area-to-perimeter ratio less than 0.5 (color blocks are elongated, the map corresponds to roads in reality, and do not belong to the planned area, so they should be deleted) and colors with an average perimeter exceeding 100 km in reality (color blocks are large in shape, corresponding to the white area at the edge of the actual map image, which also does not belong to the planned area and should be deleted). Calculate the average perimeter of the remaining colors and the area-to-perimeter ratio as the discrimination index for normal planned color blocks.
[0068] S6. Use an affine transformation-based algorithm to register the vectorized color block image. When we use the vectorized color block image, the spatial position of the image is often not where we expect it to be, and registration adjustment is required. The present invention uses the following method to adjust the spatial position of the vector image to the position where the development designer expects it to be: randomly find 4 points on the land use planning map, determine the actual longitude and latitude coordinates of the 4 points, and adjust the color block image to the position required by the designer after the affine transformation operation.
[0069] Affine transformation, also known as affine mapping, refers to a linear transformation of a vector space followed by a translation in geometry to transform it into another vector space. This mathematical operation is just suitable for the implementation of this function. The basic principle of affine transformation is explained as follows:
[0070] An affine mapping of vector translation, rotation, enlargement and reduction A is:
[0071]
[0072] Where: ——The vector before transformation
[0073] A——Rotation and scaling matrix
[0074] ——Translation (expressed as a vector)
[0075] ——The transformed vector
[0076] The above formula is equivalent to the following formula in homogeneous coordinates:
[0077]
[0078] ——The meanings of the letters in the formula are the same as above
[0079] like Figure 3 As shown, let the coordinates of point P in the original coordinate system be (X SP , Y SP ), the original coordinate system needs to be rotated by θ X =θ Y The new coordinate system is obtained by changing the angle of . Therefore, the coordinates of point P in the new coordinate system are:
[0080] (X TP , Y TP )=(X T0 +Y SP *sinθ Y +X SP *cosθ X ,Y T0 +X SP *sinθ Y +Y SP *cosθ X )
[0081] X T0 , Y T0 ——The coordinates of the origin of the original coordinate system in the new coordinate system
[0082] X SP , Y SP ——The coordinates of point P in the original coordinate system
[0083] θ X ,θ Y ——The angle of rotation from the old coordinate system to the new coordinate system, θ X =θ Y
[0084] X TP , Y TP ——The coordinates of point P in the new coordinate system
[0085] At this time, if you select 4 points in the figure and determine their point coordinates in the original coordinate system, and enter the actual latitude and longitude coordinates of each selected point, you can get 4 pairs of (X SP , Y SP ) and (X TP , Y TP ). According to the above formula, reverse calculation of X T0 , Y T0 and θ, the vector diagram can be moved to the position required by the designer by performing translation and rotation based on these three values.
[0086] From the above description, it can be seen that this embodiment uses a vectorization algorithm to vectorize the land use planning color block map in PNG format, realizes computer automation operation, and liberates human resources from traditional CAD tracing and drawing work.
[0087] This embodiment uses the potrace algorithm to import the binarized raster image into the calculation to obtain the vectorized image. This method uses the technical path of first binarization and then vectorization calculation and finally re-assigning the color, which reduces the short-term information processing amount of the hardware system and improves the stability and reliability of the results.
[0088] This embodiment adopts a registration algorithm based on affine transformation to adjust the vectorized image to the spatial position required by the designer. This method has the advantages of simple and reliable algorithm and high operation speed.
[0089] Note that references in the specification to "one embodiment," "an embodiment," "an example embodiment," "some embodiments," etc. indicate that the described embodiments may include a particular feature, structure, or characteristic, but each embodiment may not necessarily include the particular feature, structure, or characteristic. Moreover, such phrases do not necessarily refer to the same embodiment. In addition, when a particular feature, structure, or characteristic is described in conjunction with an embodiment, whether or not explicitly described, it would be within the knowledge of a person skilled in the art to implement such feature, structure, or characteristic in conjunction with other embodiments.
[0090] The previous description of the disclosure is provided to enable any person skilled in the art to make or use the disclosure. Various modifications to the disclosure will be apparent to those skilled in the art, and the general principles defined herein may be applied to other variations without departing from the spirit or scope of the disclosure. Thus, the disclosure is not intended to be limited to the examples and designs described herein, but should be granted the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for generating a GIS map, characterized in that: include: Step 1, obtain the color block image; Step 2, determining the number of colors according to the range of the zoning map and discretizing the image colors of the color block map according to the number of colors; Step 3, convert the discretized image into a binary image, and use a vectorization algorithm to obtain a vector map of the corresponding color block; Step 4, identify the black vector image and calculate the average perimeter and area of each color block; Step 5, corroding and filtering the black corresponding vector map according to the average perimeter and area obtained in step 4, extracting the real black block, and recoloring the binary image according to the color value list; Step 6, registering the recolored vectorized color block image using an affine transformation algorithm; Wherein, the step 5 specifically includes the following sub-steps: Step 501, calculating the average perimeter, area-to-perimeter ratio, and area-to-perimeter square ratio of color blocks in non-black areas, eliminating colors with an average area-to-perimeter ratio less than a preset value and an average perimeter greater than a preset value, and calculating the average color block perimeter and area-to-perimeter ratio of the remaining colors as a discrimination index for normal planning color blocks; Step 502, calculate the average color block area perimeter ratio r of the black area, and shrink the color block inward by a constant multiple of r.
2. A method for generating a GIS map according to claim 1, characterized in that: The step 2 specifically includes the following sub-steps: Step 201, scaling the input image according to actual needs to adjust the image to the most appropriate size; Step 202, quantizing the color types contained in the image to determine the number of color types contained in the original raster image; Step 203 , by comparing the similarity of each color, the number of colors in the image is reduced to a specified value, and a list of color values is obtained from the quantized image.
3. The method for generating a GIS map according to claim 1, characterized in that: In step 5, the color of the color block before vectorization in step 2 is reassigned to the corresponding vector color block.
4. The method for generating a GIS map according to claim 1, characterized in that: In step 6, several points are selected on the map, the actual latitude and longitude coordinates of the selected points are confirmed, and the color block map is adjusted to the position required by the designer through affine transformation calculation.
5. A GIS map generation device, characterized in that: include: A color block acquisition module is used to acquire a color block image; A discretization processing module determines the number of colors according to the range of the zoning map and discretizes the image colors of the color block map according to the number of colors; The vector graphics processing module converts the discretized image into a binary image and uses a vectorization algorithm to obtain the vector graphics of the corresponding color blocks; Vector map calculation module, identifies black vector map and calculates the average perimeter and area of each color block; The vector graphics coloring module erodes and filters the black corresponding vector graphics according to the average perimeter and area, extracts the real black blocks, and recolors the binary image according to the color value list; The image registration module uses an affine transformation algorithm to register the re-colored vectorized color block image; The vector graphics coloring module performs the following sub-steps: Step 501, calculating the average perimeter, area-to-perimeter ratio, and area-to-perimeter square ratio of color blocks in non-black areas, eliminating colors with an average area-to-perimeter ratio less than a preset value and an average perimeter greater than a preset value, and calculating the average color block perimeter and area-to-perimeter ratio of the remaining colors as a discrimination index for normal planning color blocks; Step 502, calculate the average color block area perimeter ratio r of the black area, and shrink the color block inward by a constant multiple of r.
6. A GIS map generating device according to claim 5, characterized in that: The discretization processing module performs the following steps: Step 201, scaling the input image according to actual needs to adjust the image to the most appropriate size; Step 202, quantizing the color types contained in the image to determine the number of color types contained in the original raster image; Step 203 , by comparing the similarity of each color, the number of colors in the image is reduced to a specified value, and a list of color values is obtained from the quantized image.
