Method for automatically generating city road network from osm map data
By downloading data from OpenStreetMap and using pgsql database and spatial clustering analysis to generate urban road networks, the problem of not being able to directly generate complete road networks in existing technologies is solved. This enables independent display and functional expansion of road networks, facilitating convenient operation and efficient application.
Patent Information
- Application Number
- CN202310814712.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-03
- Publication Date
- 2026-01-20
- Estimated Expiration
- 2043-07-03
AI Technical Summary
Existing technologies cannot directly generate complete urban road networks. They rely on simulation technology and have poor functional scalability. They cannot easily display information such as intersections, lines, and road junctions in OSM data, nor can they easily bind intersections to traffic signals, detectors, and other equipment, or bind real-time traffic information.
By downloading map data from OpenStreetMap, processing node, route, and intersection information using the pgsql database, and applying spatial clustering analysis to generate a complete urban road network, including initializing node, route, intersection, and intersection attribute information, using the ST_ClusterDBSCAN function to perform spatial clustering, generating intersection geographic information, and performing attribute calculations.
It can directly generate independent and complete urban road networks, clearly displaying the relationship and attribute information of each route and intersection, making it easy to operate. It supports the synchronization of information from devices such as traffic lights and video detectors, and has powerful functional scalability.
Smart Images

Figure CN116821267B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of road traffic graphics processing technology, and particularly relates to a method for automatically generating a city road network from OSM map data. BACKGROUND
[0002] OpenStreetMap, abbreviated as OSM, is a free and open editable map service for the public. Compared with other spatial geographic data, OSM has the advantages of free data, timely updates, and availability of data in underdeveloped and sensitive areas, and meets certain quality specifications in terms of positional accuracy, thematic accuracy, consistency, and completeness. In the field of transportation, the data can be downloaded and imported into a traffic simulation system to quickly generate a corresponding road network.
[0003] However, the downloaded OSM data does not have the concepts of intersections, lines, and road junctions, which makes it impossible to directly form a city road network from the downloaded data. In addition, in the field of transportation, most of the OSM data is downloaded and imported into a traffic simulation system to generate a corresponding road network, which has high requirements for the format of the imported basic data, and the generated road network has poor scalability. Specifically, the poor scalability of the generated road network mainly reflects in the following aspects: the completeness of road junction mapping; the binding of road junctions with signal machines, detectors, and other devices; and the extension application of road condition information binding, which are all important components in the study of road traffic systems.
[0004] Chinese patent CN201710856548.X, entitled "Method for automatically merging road network intersection nodes in OSM map data", specifically discloses a method for automatically merging road network intersection nodes in OSM map data. The method generates a node database and a road segment database from an OSM map data file, extracts intersection nodes that need to be merged from the two databases, and merges multiple nodes of intersections that meet certain requirements to improve the speed of road network analysis and calculation and avoid errors that may be caused by the lack of no-entry treatment for the connecting lines of the intersection entrance and exit roads. This method only processes the nodes between intersections in OSM data, and the merging result cannot be directly applied to the field of road traffic; the method of generating a road network using traffic simulation technology is also not convenient.
[0005] Chinese invention patent CN201710870496.1, the patent name is a method for quickly extracting road network in specified administrative area in OSM data, specifically discloses a method for quickly extracting road network in specified administrative area in OSM data, the method is extended and simplified to the boundary contour of the specified administrative area provided by OSM, the nodes and road segments outside the region after the extension and simplification are deleted, and finally the OSM road network data in the specified administrative area is obtained. The final OSM basic data is obtained by the method, and the basic road network elements such as intersection, line and intersection are not reflected; the result cannot be directly used in the field of road traffic, and the derivative function has poor expansibility.
[0006] Chinese invention patent CN201710861141.6, the patent name is a method for reserving existing road network data and expanding road network by using OSM data, specifically discloses a method for reserving existing road network and expanding road network by using OSM data, the method is automatically extracted from OSM data to expand the road network information and merge with the existing road network data, the user only needs to manually add the nodes and road segments of the existing road network and the boundary of the expanded road network to complete the computer network expansion work. The road network data obtained by the method still needs to apply traffic simulation technology to complete data display, and the expansibility in the field of road traffic is poor.
[0007] Therefore, the existing technical solutions still have the following three defects:
[0008] 1. There is no complete solution for generating road network from OSM data. At present, OSM data processing is all node information, and part of the attribute information in ways is applied integrally or individually. The road network data obtained in this way cannot show the correlation between points, lines and surfaces, and the attribute information between elements cannot be intuitively displayed. It is very inconvenient to process the complete road network of a city.
[0009] 2. The data processing method depends on simulation technology. OSM data itself does not have the concepts of intersection, line and intersection. The traditional processing of OSM data still needs to use traffic simulation technology to display data. This method has poor interactivity and cannot directly operate the road network for traffic-related department staff. At the same time, the staff also needs to have certain professional knowledge, which will increase the working time, manpower and financial resources to some extent.
[0010] 3. Poor function expansion. The road network obtained by the traditional method is applied to the field of road traffic, and the function is single. The updating and adjustment of the line; the editing of the intersection channelization; the superposition of the map layer; the binding of the intersection and the signal machine, the intersection and the detector and other devices; the expansion of the function of real-time road condition information binding, etc. These are important parts of the research of road traffic system. The traditional method cannot conveniently complete the expansion of these functions.
[0011] Therefore, relying on the downloaded OSM basic data, how to provide a more direct, more convenient and faster method for generating node, line and intersection information in urban road network, and expanding the functions of road, road condition, device information and other functions of the generated road network is still worth studying. SUMMARY
[0012] In order to solve the above technical problems, the present application provides a method for automatically generating urban road network from OSM map data, comprising the following steps:
[0013] S1, OSM data download and database: export the map data file of the target city from the OpenStreetMap website, establish a pgsql database, and import the preprocessed.osm suffix file into the database;
[0014] S2, initialization of node and line: give a latitude and longitude range, and after the back end receives the latitude and longitude range condition, return the overall wkt according to the latitude and longitude, query the content of the pgsql related data table by taking wkt as the condition, and obtain a group of ways content;
[0015] S3, collecting line information and perfecting road network: perfecting and adjusting the line information to ensure the accuracy of the road network;
[0016] S4, initialization of Rid: query the data in the database, obtain the intersection points between all ways, store them in a set, query all waynode information and store them in a set, group the result set according to way_id, traverse the way_id grouping set, traverse the node information of node_seq of ways in each way_id group, compare with the node in the intersection point set, finally obtain a rid information, and store it in a rid set, create a new table in the database, insert the rid set, that is, complete the initialization of rid;
[0017] S5, initialize intersection: query rid table, spatial aggregation according to intersection point, get aggregation class set, group the obtained set by class, traverse each set in the group to calculate a set of latitude and longitude, the wkt converted from the latitude and longitude is the aggregated intersection geographic information, stored in the set, create a table, insert the related information of the intersection set, that is, complete the initialization of the intersection.
[0018] S6, initialize intersection attribute information: including calculating intersection name, intersection id, administrative region code, lane information.
[0019] Further, the S1 specifically includes:
[0020] S11, open the downloaded OSM data file of the target city, find the part starting with node / way / relation, replace the original text after adding a timestamp, save the data change file with the suffix.osm format;
[0021] S12, import the OSM data file of the target city in.osm format into the newly created database using the osmosis command.
[0022] Further, the group of ways content in S2 includes node ID group string nodeIds, node ID array nodeIdsArr, way breakpoint waySplitId, and wkt content of way.
[0023] Further, the S4 specifically includes:
[0024] S41, jointly query the way_tags / way_nodes / nodes table to obtain nodeids in ways that have a repetition frequency of more than 2 times or more, that is, intersection points, and store the nodeid and corresponding wkt result object in a set;
[0025] S42, query the way_nodes table to obtain a result object stored in a set, and group the set by wayid to form a wayid map;
[0026] S43, traverse the wayid map and traverse the node set corresponding to each wayid, establish a rid object set, compare the nodeid in the wayid with the nodeid in the intersection point set, if the nodeid in the wayid is in the intersection point set, then the node combination from the starting order to the intersection point order is the rid, and the corresponding attribute of the rid object is assigned a value;
[0027] S44, create a t_s_rid_nodes table, and insert the rid object set in batches using multiple threads while updating the rid number;
[0028] S45, convert the above data into rid structure data, create dwd_tfc_bas_rdnet_rid_info table, batch insert rid structure data, update angle, lnglat_seq, rid_type field information.
[0029] Further, the S5 specifically includes:
[0030] S51, create t_s_cross_node table;
[0031] S52, spatial clustering analysis according to intersection points: joint query dwd_tfc_bas_rdnet_rid_info table and nodes table, apply ST_ClusterDBSCAN() function, st_x() function, st_y() function, st_astext() function, get the clustering result set related to the intersection node, including nodeid, cid, node_lat, node_lon, wkt information, spatial clustering function ST_ClusterDBSCAN(geom, eps, minpoints), use the required distance (eps) and density (minpoints) parameters to build each cluster, where geom represents the target geometry object, eps represents the required minimum distance, minpoints represents the minimum number of objects in the neighborhood required to become a core object;
[0032] S53, establish intersection object set: the clustering result is grouped according to the class cid, traverse the set of each class, calculate the aggregated center point mainNode, calculate the longitude and latitude lng, lat; judge whether the intersection node is modified by human, if yes, the intersection node belongs to the intervention intersection node; fill the calculation result mainNode, lng, lat into the intersection object and insert it into the intersection object set; batch update data to the t_s_cross_node table.
[0033] Further, the S6 specifically includes:
[0034] S61, create dwd_tfc_bas_rdnet_cross_info table; joint query
[0035] t_s_cross_node / dwd_tfc_bas_rdnet_cross_info table, the query result set is grouped according to the crossid, the dwd_tfc_bas_rdnet_cross_info table object set and the global cross name set are established, the map is traversed, the dwd_tfc_bas_rdnet_cross_info table object is newly built, the part cross attribute information name, lng, lat and nodes are calculated, the attribute information is inserted into the table object, the name is inserted into the global cross name set for judging whether there is a duplicate name; the table object is inserted into the table object set, the batch set data is updated into the table, and the cross information in the dwd_tfc_bas_rdnet_rid_info table is updated;
[0036] S62, update the administrative division and id of the cross;
[0037] S63, update the grade and cross shape of the cross: query the data in the dwd_tfc_bas_rdnet_rid_info table, judge the cross shape and road grade according to the total sum of end_cross_id, and update the table information.
[0038] Compared with the prior art, the present application has the following beneficial effects:
[0039] 1. The present application directly downloads the open source OSM map data, completes the city road network construction according to the method flowchart, and generates a road network completely independent of other functions, that is, the OSM data directly generates a complete city road network.
[0040] 2. The road network generated by the method can clearly display the relationship between each line, each cross and its respective attribute information, and also has various basic road network editing functions, which is convenient for operators to use and has strong operability, that is, the road network generated by the method can be directly applied to intelligent traffic services.
[0041] 3. Road traffic will perform a series of functional operations based on the road network to meet the needs of daily work. For example, signal machines, video detectors, electric police, and card mouth device information. These information must be synchronized to each branch or lane of the cross to play the function of the device. Based on the perfect city road network generated by the method, secondary function expansion and development can be very convenient, the integrity of the entire road network will not be damaged, the original part can be processed independently, and there will be no functional confusion, that is, the expansion of the generated road network application function is strong. BRIEF DESCRIPTION OF DRAWINGS
[0042] Figure 1 The flowchart of the present application; DETAILED DESCRIPTION
[0043] In order to make the technical solutions and technical effects of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below in combination with the drawings in the embodiments. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments.
[0044] Terminology:
[0045] rid: A road section refers to a traffic line between two adjacent nodes on a traffic network, specifically, an ordered point set with a starting point and a terminal point as nodes and a plurality of connecting points. A road is broken into many parts by intersections or topological connecting points to form road sections, and the attribute information of each road section is different. The attribute information mainly includes road section number (unique identifier of the road section), road name to which the road section belongs, road level, starting road, terminal road, and arc section set. Since the road section is broken into many arc sections at the nodes, the road section is composed of many arc sections. In addition, the attributes of the road section also include dynamic traffic information and static traffic information.
[0046] Map layer: thematic data divided according to geometric features and attributes. It can be divided into "vector layer" and "raster layer".
[0047] Road channelization: A method of setting traffic islands or traffic markings, setting up signs to guide and lead road traffic flow, and making traffic flow smooth, so as to improve road traffic capacity, driving safety, and ensure the safety of pedestrians.
[0048] As shown in Figure 1 The present application provides a method for automatically generating nodes, lines, and intersections of a city road network from OSM map data, and the specific steps are as follows:
[0049] Step 1: OSM data download and database import.
[0050] 1. Enter the OpenStreetMap website, input the city name, and download the file name OSM data of the city.
[0051] 2. Open the downloaded file, find the node / way / relation beginning part, add a timestamp and replace the original text; save the data change file suffix as.osm format.
[0052] 3. New pgsql database and create extension; new
[0053] Tables of actions / users / nodes / node_tags / ways / way_nodes / way_tags / relations / relation_members / relation_tags / schema_info.
[0054] 4. Apply osmosis command to import the city map file in.osm format into the built database.
[0055] Step 2: Initialize nodes and lines.
[0056] 1. Give a latitude and longitude range (start_lat, start_lon), (end_lat, end_lon), and then return the overall wkt according to the latitude and longitude.
[0057] 2. Take wkt as a parameter condition, and jointly query the ways / way_nodes / nodes table to obtain a set of ways-related information, including node ID group string nodeIds, node ID array nodeIdsArr, way breakpoint waySplitId, and way wkt.
[0058] Step 3: Collect line information and improve the road network.
[0059] 1. For example, add / delete nodes, lines, modify line names, directions, interchange line intersections, auxiliary road relationships between elements, and other adjustments.
[0060] 2. A series of functions such as drawing, cutting, reversing, parallel, merging points, merging lines, merging nodes to lines, splitting paths, searching, deleting, editing attribute information, switching maps, etc. are provided to improve the road network.
[0061] Step 4: Initialize Rid.
[0062] 1. Jointly query the way_tags / way_nodes / nodes table to obtain nodeids in ways with a repetition of more than 2 times or more, which are intersection points. The nodeid and corresponding wkt result object are stored in a collection.
[0063] 2. Query the way_nodes table to obtain the result object and store it in a collection; group the collection by wayid to form a map of wayid.
[0064] 3. Traverse the map of wayid, and traverse the node set corresponding to each wayid to establish the rid object set. Compare the nodeid in wayid with the nodeid in the intersection set. If the nodeid in wayid is in the intersection set, the node combination from the start sequence to the intersection sequence is the rid, and the corresponding attribute of the rid object is assigned a value.
[0065] 4. Create the t_s_rid_nodes table, and insert the rid object set in batches in multiple threads, and update the rid number.
[0066] 5. Convert the data into rid structure data, create the dwd_tfc_bas_rdnet_rid_info table, insert the rid structure data in batches, and update the angle, lnglat_seq, rid_type and other field information.
[0067] Step five: Initialize the intersection.
[0068] 1. Create the t_s_cross_node table.
[0069] 2. Perform spatial clustering analysis according to the intersection. Jointly query the dwd_tfc_bas_rdnet_rid_info table and the nodes table, apply the ST_ClusterDBSCAN() function, the st_x() function, the st_y() function, and the st_astext() function to obtain the clustering result set of the intersection node, including the nodeid, cid, node_lat, node_lon, and wkt information. The spatial clustering function ST_ClusterDBSCAN(geom, eps, minpoints) does not need to specify the cluster number, but uses the required distance (eps) and density (minpoints) parameters to construct each cluster, where geom represents the target geometry object, eps represents the required minimum distance, and minpoints represents the minimum number of objects in the neighborhood required to become a core object.
[0070] 3. Establish the intersection object set. The clustering result is grouped according to the class cid. Traverse the set of each class, calculate the aggregated center point mainNode, and calculate the longitude and latitude lng and lat. Determine whether the intersection node has been modified by human. If so, the intersection node belongs to the intervention intersection node. Fill the calculation results mainNode, lng and lat into the intersection object, and insert it into the intersection object set. Update the data in batches to the t_s_cross_node table.
[0071] Step six: Initialize the intersection attribute information.
[0072] 1, create dwd_tfc_bas_rdnet_cross_info table. Joint query
[0073] t_s_cross_node / dwd_tfc_bas_rdnet_cross_info table, the query result set is grouped according to crossid map. The dwd_tfc_bas_rdnet_cross_info table object set and the global intersection name set are established. Traverse the map, create a new dwd_tfc_bas_rdnet_cross_info table object, calculate part of the intersection attribute information name, lng, lat, nodes, wkt, and insert the attribute information into the table object. Insert name into the global intersection name set for judging whether there is a duplicate name; Insert the table object into the table object set, and update the batch set data to the table, and update the intersection information in the dwd_tfc_bas_rdnet_rid_info table.
[0074]
[0075] 2, update the administrative division and id (snowflake algorithm creates id) of the intersection.
[0076] 3, update the level and shape of the intersection. According to the requirements of appendix A data specification A18 attribute code in the national standard GB / T 39900-2021 "General technical requirements for road traffic signal control system", the data in the dwd_tfc_bas_rdnet_rid_info table is queried, the total sum of end_cross_id is used to judge the intersection shape and road level, and the table information is updated.
[0077] The method for automatically generating the city road network of nodes, lines and intersections of OSM map data provided by the application can be directly applied to road traffic in different cities as a basic road network service; It can also be extended on this basis to meet the requirements of road traffic. In addition, the road network generated by the application has high completeness, accuracy and interactivity, and is very convenient to use, which can greatly save work cost and improve efficiency.
[0078] Although embodiments of the application have been shown and described, it is to be understood that the application is not limited to the details of the foregoing embodiment, and that various changes in the form and details thereof can be made without departing from the spirit and scope of the application. The scope of the application is defined by the appended claims and their equivalents.
Claims
1. A method for automatically generating an urban road network from OSM map data, characterized in that, The method comprises the following steps: S1, OSM data download and database import: export the map data file of the target city from the OpenStreetMap website, establish a pgsql database, and import the preprocessed.osm suffix file into the database; S2, initialization of nodes and lines: give a latitude and longitude range, and after the backend receives the latitude and longitude range condition, return the overall wkt according to the latitude and longitude, query the content of the pgsql related data table according to the wkt as the condition, and obtain a group of Ways content; S3, collecting line information and perfecting road network: perfecting and adjusting line information to ensure the accuracy of road network use; S4, initialization of Rid: querying the data in the database, obtaining the intersection points between all ways, storing them in a set, querying all waynode information and storing them in a set, grouping the result set according to way_id, traversing the way_id grouping set, comparing the node information of node_seq of ways in each way_id group with the node in the intersection point set, finally obtaining a rid information, storing it in a rid set, creating a new table in the database, and inserting the rid set, that is, completing the initialization of rid; S5, initialization of intersection: querying the rid table, spatially aggregating according to the intersection points, obtaining an aggregated class set, grouping the obtained set according to the class, traversing each group of sets to calculate a set of latitude and longitude, the wkt converted from the latitude and longitude is the aggregated intersection geographic information, which is stored in a set, a table is created, and the related information of the intersection set is inserted, that is, the initialization of intersection is completed; S6, initialization of intersection attribute information: including calculation of intersection name, intersection id, administrative region code, and lane information; specifically including: S61, creating a dwd_tfc_bas_rdnet_cross_info table; jointly querying t_s_cross_node / dwd_tfc_bas_rdnet_cross_info tables, grouping the query result set according to crossid, mapping, establishing a dwd_tfc_bas_rdnet_cross_info table object set and a global intersection name set, traversing the map, newly creating a dwd_tfc_bas_rdnet_cross_info table object, calculating part of the intersection attribute information name, lng, lat, nodes, and wkt, inserting the attribute information into the table object, inserting name into the global intersection name set for judging whether there is a duplicate name, inserting the table object into the table object set, updating the batch set data to the table, and updating the intersection information in the dwd_tfc_bas_rdnet_rid_info table at the same time; S62, updating the administrative division and id of the intersection; S63, update the level and shape of the intersection: query the data in the dwd_tfc_bas_rdnet_rid_info table to determine the intersection shape and road level according to the total number of end_cross_id, and update the table information.
2. The method of claim 1, wherein the OSM map data automatically generates a city road network, and The S1 specifically comprises: S11, open the downloaded OSM data file of the target city, find the part starting with node / way / relation, replace the original text after adding a timestamp, save the data change file with the suffix.osm format; S12, apply the osmosis command to import the OSM data file of the target city in.osm format into the newly created database.
3. The method of claim 1, wherein the OSM map data automatically generates a city road network, and The group of Ways content in the S2 includes a node ID group string nodeIds, a node ID array nodeIdsArr, a way breakpoint waySplitId, and wkt content of the way.
4. The method of claim 1, wherein the OSM map data automatically generates a city road network, and The S4 specifically comprises: S41, jointly query the way_tags / way_nodes / nodes table to obtain nodeids in the ways that have a repetition number of more than 2 times or more, that is, intersection points, and store the nodeid and the corresponding wkt result object in a set; S42, query the way_nodes table to obtain a result object and store it in a set, and group the set by wayid to form a map of wayid; S43, traverse the map of wayid, traverse the node set corresponding to each wayid, establish a rid object set, compare the nodeid in the wayid with the nodeid in the intersection point set, if the nodeid in the wayid is in the intersection point set, then the combination of the node from the start sequence to the intersection point sequence is the rid, and the corresponding attribute of the rid object is assigned a value; S44, create a t_s_rid_nodes table, and insert the rid object set in batches and update the rid number in multiple threads; S45, convert the above data into rid structure data, create the dwd_tfc_bas_rdnet_rid_info table, insert the rid structure data in batches, and update the angle, lnglat_seq, and rid_type field information.
5. The method of claim 1, wherein the OSM map data automatically generates a city road network, and The S5 specifically comprises: S51, create a t_s_cross_node table; S52, according to the intersection point, carry out spatial clustering analysis: joint query dwd_tfc_bas_rdnet_rid_info table and nodes table, apply ST_ClusterDBSCAN () function, st_x () function, st_y () function, st_astext () function, get the clustering result set related to the intersection node, contain nodeid, cid, node_lat, node_lon, wkt information, spatial clustering function ST_ClusterDBSCAN (geom, eps, minpoints), use the required distance eps and density minpoints parameter to build each cluster, wherein geom represents the target geometry object, eps represents the required minimum distance, minpoints represents the minimum number of objects in the neighborhood required to become a core object; S53, establish intersection object set: clustering result is grouped according to class cid, traverse each class set, calculate the center point mainNode of aggregation, calculate longitude and latitude lng, lat;Judge whether the intersection node is modified by human, if yes, the intersection node belongs to the intervention intersection node;The calculation result mainNode, lng, lat is filled into the intersection object and inserted into the intersection object set;Batch update data to the t_s_cross_node table.
Citation Information
Patent Citations
A method for preserving existing road network data and using OSM data for road network expansion
CN107403020B
A method for automatically merging road network intersection nodes in OSM map data
CN107704531B
A method for quickly extracting road networks within a specified administrative region from OSM data
CN107704540B
Rapid traffic demand estimation method for urban traffic simulation
CN115565368A
Method for generating accurate lane level maps
US20150117723A1