Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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:… – Mike Honeychurch Jun 12 '14 at 0:06
The gist of my code is trying to set up a coordinate system to get relative distances for a power grid system. – David Jun 12 '14 at 0:42
I put the pastebin to my code above for help to see if the code will suffice for my needs – David Jun 12 '14 at 0:42
This is what I get as my error message. – David Jun 12 '14 at 1:40
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 – Mike Honeychurch Jun 12 '14 at 2:43

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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