PostgreSQL to graph-tool

I'm interested in calculating some centrality measures on a road network of
a city. The geometry of the road network, from Open Street Map, is stored
in a postgreSQL / postGIS database and can also be exported as a shapefile
or a geojson. What is the best way to import the geometry in graph-tool as
a planar graph?
Thank you,

attachment.html (362 Bytes)

Hi Duccio Aiazzi,

I don't have an answer to your specific question, but I just want to call
your attention to the OSMnnx , which makes it incredibly simple to create a
road network from OpenStreetMaps data with a single line of code.

OSMnnx also allows one to save the graph as a GraphML file, which I
believe can be easily read by graph-tool as a planar graph if I'm not


Rafael H M Pereira

attachment.html (2.02 KB)

It seems to me this is by far the easiest choice.

In addition to exporting to graphml, it is also simple to iterate over the
edges of the OSMnnx graph and add them to a graph-tool graph.

(Note that road networks need not to be planar; they may contain bridges and