I have a network of a power grid where the edge are the power lines and the vertices are loads or generators. I was wondering how I can import an image into Mathematica to derive some sort of coordinate system to calculate some topological properties that are related to distance and position using Monte Carlo Cooling methods and other methods of this sort. The code below is giving me back errors that are shown below.

im = Import["C:\Research\Pictures\FloridaPowerGrid.jpg"];
Module[{picturesize, i, bigger, imagesizes}, 
  picturesize = {1038, 1386};
  values = {};
  i = 1;
  imagesizes = ImageDimensions[im]; bigger = 1;
  DynamicModule[{pt = {0, 0}},
   If[imagesizes[[1]] < imagesizes[[2]], bigger = 2];
    Button["Record!", AppendTo[values, {i, pt}]; i++;], 
      Dynamic @ Graphics[
          {Inset[im, {0, 0}, {0, 0}, {1, 1}]}, 
          Flatten[{Blue, Disk[#[[2]], .01], White, Text[#[[1]], #[[2]]]} & /@ values]], 
        PlotRange -> 
          {{0, imagesizes[[1]]/imagesizes[[bigger]]}, 
          {0, imagesizes[[2]]/imagesizes[[bigger]]}}, 
        ImageSize -> picturesize]], 
    Dynamic[N @ pt], 

enter image description here

enter image description here

  • $\begingroup$ the short answer is yes but the long answer is complicated and requires more info. Are you wanting to use locators to get coords of points on the image? If so this post might offer some ideas: mathematica.stackexchange.com/questions/3831/… $\endgroup$ Jun 12, 2014 at 0:06
  • $\begingroup$ The gist of my code is trying to set up a coordinate system to get relative distances for a power grid system. pastebin.com/sMJWJNfP $\endgroup$
    – David
    Jun 12, 2014 at 0:42
  • $\begingroup$ I put the pastebin to my code above for help to see if the code will suffice for my needs $\endgroup$
    – David
    Jun 12, 2014 at 0:42
  • $\begingroup$ This is what I get as my error message. imgur.com/V3eQlib $\endgroup$
    – David
    Jun 12, 2014 at 1:40
  • $\begingroup$ It is not a good idea to have Module values that you intend to use dynamically. Get rid of Module and bring everything into your dynamic module and try again $\endgroup$ Jun 12, 2014 at 2:43

1 Answer 1


The problem was with importing the picture. It had to be.jpg.jpg since I saved it as FloridaPowerGrid.jpg but it automatically adds .jpg when saved. I appreciate all the help and effort from this community.


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.