Google Answers Logo
View Question
 
Q: Calculating an X and Y point from Latitude and Longitude ( No Answer,   0 Comments )
Question  
Subject: Calculating an X and Y point from Latitude and Longitude
Category: Computers > Programming
Asked by: tommy2005-ga
List Price: $15.00
Posted: 14 Dec 2005 19:06 PST
Expires: 15 Dec 2005 23:25 PST
Question ID: 606014
I'm trying to convert a latitude and longitude to an x and y point on
a map.  The map in question is a Mercator projection (see
http://en.wikipedia.org/wiki/Mercator_projection).  Longitude(x) is
very easy but I'm having trouble programmatically calculating
latitude(y), since it's obviously not linear.

I have various maps that I can use (different sizes and layouts) but
all are the same projection (Mercatur) and in each case,  I know the
pixel offset of 0,0.  For example, suppose a given map was 800 pixels
wide and 500 pixels high and was perfectly centered, I know that at
pixel 400x250 is latitude 0 longitude 0.  I know the top of the map is
at row 0 (latitude 86.0000 or thereabouts, since the 90 degree point
is infinite), so assuming mercator projection I'd like to calculate
the Y point (0-500, with 250
being a latitude of 0) given a certain latitude.  I obviously know a
latitude of 45.0000 is between pixel 0 and 250, but can't seem to
calculate the correct pixel using the formula on the wikipedia entry.

Programmatically I'm using .NET (C#, but any .NET language is good) so
an answer that includes an example in .NET is ideal.

Clarification of Question by tommy2005-ga on 15 Dec 2005 13:34 PST
Clarification:

I can calculate the scale based on the formula:

z = ln(tan(latitude/2 + pi/4))
where latitude is the latitude in radians.

The challenge is applying that value correctly given an arbitrary map
height n.  I do know, though, where latitude 0 and, say, latitude 60
is on the map, so can calculate the pixel difference between them.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy