Sample program for drone world graph:
import pandas as pd
import city2graph as c2g
from city2graph.graph import GraphBuilder
from city2graph.utils import parse_location
# Load the CSV file
df = pd.read_csv("drone_objects.csv")
# Parse location into coordinates (assuming location is in "lat,lon" format)
df[['lat', 'lon']] = df['location'].apply(lambda loc: pd.Series(parse_location(loc)))
# Initialize the graph builder
builder = GraphBuilder()
# Add nodes for each object
for _, row in df.iterrows():
node_id = f"obj_{row['object_id']}_frame_{row['frame_id']}"
builder.add_node(
node_id,
timestamp=row['timestamp'],
location=(row['lat'], row['lon']),
created=row['created']
)
# Optional: Add edges based on spatial proximity (within 50 meters) or temporal continuity
builder.connect_nodes_by_proximity(max_distance=50) # meters
builder.connect_nodes_by_sequence(time_window=5) # seconds
# Build the graph
graph = builder.build()
# Visualize or export the graph
graph.plot(title="Drone Object Detection Graph")
# graph.export("drone_graph.gml") # Optional export
No comments:
Post a Comment