I have a map (in image format) describing the power grid of a continent.

Power plants have flags next to them, indicating their type (hydro, gas, oil, etc.). The power lines have a color indicating their tensions (different voltages). The cities are marked as black dots.

Here's a piece of the map, courtesy of the ENTSO-E consortium Iceland power grid

Full maps here. Things get much more complex in populated area.

As you can see, the power lines are often overlapping each other. Moreover they are not simple straight lines. Two cities (points) can be connected by a broken line, with no middle point in between.

I need to turn that map image into a graph (dataset). The broken lines may be straightened and have their full length marked as the weight of the arc. Or they may be handled by inserting middle points.

I'd like to automatize as much work as I can, but, since the map is so complex, I understand I'll probably need some manual tool to do the final pass.

What would you suggest?

I think finding the power-plants should be possible using an automatic tool, then corrections and addition of arcs could be done using an assisted manual tool.

EDIT: perhaps this is something that can be done with a plugin for GIS software? If programming is involved, my favorite languages are Java and Python. I know C++ too.


1 Answer 1


Start by getting rid of the background (Mathematica example):

map = Import["https://i.sstatic.net/HYtbo.jpg"]

fg = ImageAdjust[map, {1.0, 1.0}]


Then use a graph extraction tool like NEFI. If you want to do it all in Mathematica, that's possible too. You might want to add another preprocessing step to decompose the graph by edge type if you want to treat them separately, like you said.

  • $\begingroup$ I don't know much about Mathematica, but I can use Python. The image is not a proper graph, because of the broken lines changing direction without stopping at a node. Think NEFI can work on it, perhaps adding extra nodes? $\endgroup$
    – Agostino
    Commented Jan 22, 2016 at 21:11
  • $\begingroup$ Which broken line? Even BRE-SUL has a connected line. Is this not a representative image? The image processing required is elementary because the maps are very clean, so you can easily do it in python. $\endgroup$
    – Emre
    Commented Jan 22, 2016 at 21:18
  • $\begingroup$ I mean things like PRE-HOL, on the lower right. I don't just want a straight line connecting the two nodes/power plants. I want to preserve those up and downs the line makes. GIS software uses broken lines by default (saving the breaking points). Moreover, populated areas are much more complex. Full maps here. $\endgroup$
    – Agostino
    Commented Jan 23, 2016 at 11:44
  • 1
    $\begingroup$ Then take a two-step approach: vectorize the image extracted as above, and separately infer the graph using NEFI. The vector image will preserve the shape, and the graph will tell you which nodes are connected. $\endgroup$
    – Emre
    Commented Jan 23, 2016 at 18:51
  • $\begingroup$ A very interesting suggestion! +1 x2 $\endgroup$
    – Agostino
    Commented Jan 23, 2016 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.