title: Mercator longitude and latitude calculations to x and y on a cropped map (of the UK)
body: <p>I have this image. It's a map of the UK (not including Southern Ireland):</p>
  
  <p><a href="https://i.stack.imgur.com/KUcpE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KUcpE.png" alt="UK Map"></a> </p>
  
  <p>I have successfully managed to get a latitude and longitude and plot it onto this map by taking the leftmost longitude and rightmost longitude of the UK and using them to work out where to put the point on the map.</p>
  
  <p>This is the code (for use in Processing.js but could be used as js or anything):</p>
  
  <pre><code>// Size of the map
  int width = 538;
  int height = 811;
  // X and Y boundaries
  float westLong = -8.166667;
  float eastLong = 1.762833;
  float northLat = 58.666667;
  float southLat = 49.95;
  
  void drawPoint(float latitude, float longitude){
  
   fill(#000000);
  
   x = width * ((westLong-longitude)/(westLong-eastLong));
   y = (height * ((northLat-latitude)/(northLat-southLat)));
  
   console.log(x + ", " + y);
   ellipseMode(RADIUS);
   ellipse(x, y, 2, 2);    
  
  }
  </code></pre>
  
  <p>However, I haven't been able to implement a Mercator projection on these values. The plots are reasonably accurate but they are not good enough and this projection would solve it.</p>
  
  <p>I can't figure out how to do it. All the examples I find are explaining how to do it for the whole world. <a href="http://wiki.openstreetmap.org/index.php/Mercator" rel="nofollow noreferrer">This</a> is a good resource of examples explaining how to implement the projection but I haven't been able to get it to work.</p>
  
  <p>Another resource is the <a href="http://en.wikipedia.org/wiki/Extreme_points_of_the_United_Kingdom" rel="nofollow noreferrer">Extreme points of the United Kingdom</a> where I got the latitude and longitude values of the bounding box around the UK. They are also here:</p>
  
  <pre><code>northLat = 58.666667; 
  northLong = -3.366667; 
  eastLat = 52.481167; 
  eastLong = 1.762833; 
  southLat = 49.95;
  southLong = -5.2; 
  westLat = 54.45;
  westLong = -8.166667;
  </code></pre>
  
  <p>If anyone could help me with this, I would greatly appreciate it!</p>
  
  <p>Thanks</p>