-1

enter image description herehello all I am trying to find this Number

from this question : Convert longitude and latitude coordinates to image of a map pixels X and Y coordinates Java

 int mapWidth = 614, mapHeight = 1141;
    double mapLongitudeStart = 33.5, mapLatitudeStart = 33.5;//longitude vertical, latitude horizontal
    // length of map in long/lat
    double mapLongitude = 36.5 - mapLongitudeStart,
    // invert because it decreases as you go down
    mapLatitude = mapLatitudeStart - 29.3;

how can i find this number from the world map image

Ameer
  • 1
  • 5
  • i need to know where he get this number and i need this number for my image here is my image https://i.stack.imgur.com/Q58wm.gif – Ameer Jan 28 '23 at 18:26
  • Looking at your current image which is 1200 x 715 pixels and the fact that **Prime Meridian** runs longitudinally through Greenwich Park in London England (there is actually a landmark there) which is considered 0 degrees Longitude up and down the globe and the fact that the **Equator** basically runs laterally through Singapore across the globe and is considered 0 degrees latitude, this makes Prime Meridian 561 pixels from left edge of image and the Equator 461 pixels from top edge of image. If the Lat and long grid is 30 degrees then the grid is approx. 30 x 30 pixels over the globe (FLAT). – DevilsHnd - 退職した Jan 29 '23 at 10:33
  • this formula give me the wrong postion in the image X = (Longitude + 180) * (1200 / 360) + 561 Y = (90 - Latitude) * (715 / 180) + 461 – Ameer Jan 29 '23 at 23:52

1 Answers1

0

Try this:

int mapWidth = 614, mapHeight = 1141;
double mapLongitudeWidth = 36.5, mapLatitudeHeight = 29.3;
double mapLongitudeStart = 33.5, mapLatitudeStart = 33.5;//longitude vertical, latitude horizontal
// length of map in long/lat
double mapLongitude = mapLongitudeWidth - mapLongitudeStart;
// invert because it decreases as you go down
double mapLatitude = mapLatitudeStart - mapLatitudeHeight;

int xImagePos = (int) (mapWidth * (mapLongitude/mapLongitudeWidth));
int yImagePos = (int) (mapHeight * (mapLatitude/mapLatitudeHeight));

System.out.println("x: " + xImagePos + ", y: " + yImagePos);

It does seem odd that both mapLongitudeStart and mapLatitudeStart are 33.5. Typo?

John Williams
  • 4,252
  • 2
  • 9
  • 18