have a map image 800px wide. How can I figure out a city.

like New York has 40.75 latitude and -73.98 longitude. I have to pin a mark over this point.

Before I have done with x_axis and y_axis which gives problem on more cities figure because i manually had to input values. now i have database with all cities with latitude and longitude. or is there any way that i can convert latitude and longitude to x and y axis.

Thank you


x = image.width * (longitude + 180) / (2 * 180)
y = image.height * (latitude + 180) / (2 * 180)

The maths is pretty easy if you want to do it by hand(or in the database) but you will probably be best served by setting up a desktop GIS to draw the output image once or if you need interactivity then a web map server will be a better way to go.

  • For now i have latitude and longitude stored in database. I have to calculate x coordinate and y-coordinate of a image map and point the place on the coordinate. what will be the exact calculation. please see the codes to calculate on edit section up. this doesn't gives accurate coordinates. – kamal Jul 12 '11 at 10:16
  • 1
    with only 400x800 pixels to play with how accurate do you expect? – Ian Turton Jul 12 '11 at 12:07
  • Definitely I want accurate data. It it is possible as I am doing please advice. else I will search for gis disktop etc.. – kamal Jul 12 '11 at 13:15
  • 1
    well by my calculations you can't get better than .45 degree per pixel for that size of image. – Ian Turton Jul 12 '11 at 13:20
  • 1
    @iant It looks like the Robinson projection. The formulas are available. @kamal: look at those formulas. They will give an appreciation for what GIS software does. Do you really want to reinvent this wheel? If so, then pick a real simple projection, such as Plate Carree. – whuber Jul 12 '11 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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