Search code examples
pythongephibrightway

How to export Ecoinvent 3.5 Database with brightway2 to GEXF file?


I would like to Export a brightway2 database to a gexf file to visualize it with Gephi, like here: https://chris.mutel.org/visualizing-ecoinvent.html

When I try to Export it, I get a KeyError.

my code is:

import brightway2 as bw
from bw2io.export.gexf import DatabaseToGEXF
gephi = DatabaseToGEXF("ecoinvent 3.5 cutoff")
gephi.export()

Can someone help me with that?


Solution

  • This would be more properly filed as a bug report.

    This bug was fixed in 0.7.6, released today via the normal channels. However, the previous visualization you linked to was built on the categories present in ecoinvent version 2. Version 3 no longer has these categories (though other similar metadata is possible). Moreover, the linked visualization required a lot of manual work (especially for the labelling).

    So, creating a similar visualization for a recent ecoinvent is possible, but not easy :) My guess is you would have to write a custom DatabaseToGEXF subclass that will export the metadata you are interested in using for graph clustering/coloring/etc.