How do I get edges and vertices from an OSM map?

9 ビュー (過去 30 日間)
Srinivasan V
Srinivasan V 2022 年 11 月 13 日
回答済み: Harsh 2025 年 7 月 24 日
I am looking for means to import edges and vertices from OSM map to finally make a good digraph. Can please someone help me? Automated driving toolbox imports the map but unable to fetch egdes and vertices from it.

回答 (1 件)

Harsh
Harsh 2025 年 7 月 24 日
You can use the "OpenStreetMap" Functions package from MATLAB File Exchange. This toolset is specifically designed for exactly what you're trying to do - it can import OSM files and extract the adjacency matrix representing the road network connectivity.
Using this package you can:
  • Import and parse OSM XML files into MATLAB structures
  • Extract the adjacency matrix of the directed graph representing road intersections
  • Find shortest routes between nodes in the network
  • Plot the transportation network with nodes and labels
% Basic usage example
map = parse_openstreetmap('your_map_file.osm');
plot_openstreetmap(map);
[adjacency_matrix, intersection_nodes] = extract_connectivity(map);
% Create digraph from the adjacency matrix
G = digraph(adjacency_matrix);
Please refer to the following File Exchange page for more information regarding "OpenStreetMap" Functions - www.mathworks.com/matlabcentral/fileexchange/35819-openstreetmap-functions.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by