Skip to content

Instantly share code, notes, and snippets.

@cocomoff
Created May 29, 2018 13:48
Show Gist options
  • Save cocomoff/1cecbea414a063494696c1ec8caf08a7 to your computer and use it in GitHub Desktop.
Save cocomoff/1cecbea414a063494696c1ec8caf08a7 to your computer and use it in GitHub Desktop.
Naive OSM parsed pickle plot viewer
# -*- coding: utf-8 -*-
import pickle
import networkx as nx
import matplotlib.pyplot as plt
G = pickle.load(open("GG.pickle", "rb"))
print(G.number_of_nodes())
print(G.number_of_edges())
pos = {}
for n, data in G.nodes(data=True):
pos[n] = (float(data["y"]), float(data["x"]))
fig = plt.figure(figsize=(8, 7))
ax = plt.gca()
node = nx.draw_networkx_nodes(G, pos, node_size=10)
node.set_edgecolor('k')
nx.draw_networkx_edges(G, pos, lw=1, alpha=0.9, arrows=False)
ax.axis("off")
ax.margins(0)
ax.set_position([0, 0, 1, 1])
plt.savefig("output.png", dpi=150)
plt.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment