Download the lastest linux release
If you trust/verified this code, make it executable and add it to your path
sudo chmod +x ophois
sudo mv ophois /usr/local/bin
cargo build --release # >= Rust 1.58
# output should be in /target/release/ophois
CITY=Pantin # Save your city in an environment variable
ophois download --city $CITY
cat $CITY.osm | ophois format | ophois extract > $CITY-extracted.graph
same command with space separator
NOTE: Default separator is "␟" ASCII 31 (0x1F) Unit Separator but you can use any suitable separator as long you specify it with --separator
cat $CITY.osm | ophois format | ophois extract --separator ' ' > $CITY-extracted.graph
The tool used to generate the following screenshots is cartographe
keep the largest component, remove degree two nodes, replace nodes with under delta links by links and replace links (and nodes) which distance is under delta by a midpoint node connected to neighbours
cat $CITY-extracted.graph | ophois simplify --delta 10.0 > $CITY-simplified.graph
NOTE: delta=6
NOTE: delta=6
cat $CITY-simplified.graph | ophois discretize --delta 6.0 > $CITY-discretized.graph
NOTE: delta=6
ophois download --city $CITY; cat $CITY.osm | ophois format | ophois extract | ophois simplify --delta 10 | ophois discretize --delta 5 > $CITY.graph
same command with space separator
ophois download --city $CITY; cat $CITY.osm | ophois format | ophois extract -s ' ' | ophois simplify -s ' ' -d 10 | ophois discretize -s ' ' -d 5 > $CITY.graph
NOTE: Default separator is "␟" ASCII 31 (0x1F) Unit Separator
node_id␟latitude␟longitude #represents a node
node_id␟latitude␟longitude
node_id␟node_id #represents a link
node_id␟node_id
3758221295␟48.8275185␟2.3484976 #represents a node
3761637488␟48.8275416␟2.3486683
3761637488␟3758221295 #represents a link
import networkx as nx
# Create an empty graph object
G = nx.Graph()
# Open the file for reading
with open("ophois-graph.txt", "r") as f:
# Loop through each line in the file
for line in f:
# Remove any leading or trailing white space characters
line = line.strip()
# Split the line using the ␟ separator
fields = line.split('␟')
# Check the length of the line to determine whether it is a node or an edge
if len(fields) == 3:
# This is a node, add it to the graph
node_id = fields[0]
latitude = float(fields[1])
longitude = float(fields[2])
G.add_node(node_id, latitude=latitude, longitude=longitude)
elif len(fields) == 2:
# This is an edge, add it to the graph
node1 = fields[0]
node2 = fields[1]
G.add_edge(node1, node2)
# Print the nodes and edges in the graph
print("Nodes:", G.nodes())
print("Edges:", G.edges())
# Write the graph to a GraphML file
nx.write_graphml(G, "output.graphml")