Skip to content

vinhnguyen-lhv/generate-weighted-graph

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

generate-weighted-graph

Description

This script use to generate weighted graph from OpenStreetMap data

output

There are 4 kinds of output:

1. images/images.png: image of graph with highlight source and destination
2. nodes_origin.csv: list of nodes in graph generated from OpenStreetMap.
   edges_origin.csv: list of edges in graph generated from OpenStreetMap.
3. adj_list.json: adjacency list as json format.
4. graph.graphml: graphml format of graph for later plotting.

Usage

Prerequisites

install required packages

pip3 install -r requirements.txt
include area of map you want to generate graph in areas_list.txt
---
areas:
  - "Quận 10"
  - "Quận 3"
  - "Quận 1"

or you can use bbox to specify the area which more accurate than above method, if you specify both, bbox will be used. bbox is in format of [north, south, east, west]

bbox: [10.7880, 10.7591, 106.7048, 106.6556]

include source and destination for highlight in areas_list.txt (optional, still manually find the node id)

src_node: 2302073725 # Đai học Bách Khoa
dest_node: 11221021745 # Chợ Bến Thành

include custom filter for flexibility shrink the data (you will thank me later when dealing with Floyd-Warshall algorithm)

custom_filter: '["highway"~"primary|secondary|tertiary"]'

run script

python3 osmnx2graph.py

About

for IMP MATH class group project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%