Converting lat/long distance to miles.

Camden Daily cdaily at GMAIL.COM
Wed Jan 26 16:34:45 EST 2005


Ok, I need some help with this one.  I have a map where all the layers
are in lat/long coordinates, so I don't do any projections.

I use queryByPoint and distanceToShape to find the closest item in a
shapefile to a given point (nearest subway stop, for example).  I have
all this working just fine, but the distance I receive from
distanceToShape is in decimal degrees.  I'd like to convert this to
miles.

Anyone have a good solution?  The result doesn't need to be too
precise, but the more precise the better.  The issues I see as causing
problems are:

1) Degrees of longitude vary in length the further north you are.  My
map only covers a limited area (northern Illinois) so I wouldn't be
adverse to using a 'fixed' value for that conversion, but if I could
be more exact I'd like to be.

2) The distance I have doesn't tell me anything about the direction;
if two points are of equal distance in latlong, one to the east or
west would actually be 'closer' than one to the north or south,
correct (unless you're at the equator);

I'm guessing I'll have to calculate the difference in latitude,
convert it to miles, then calculate the difference in longitude,
convert it to miles, and then use the pythagorean theorem to calculate
the distance.  Is this sounding correct?  Or for distances under 2
miles will this even make a noticeable difference?

Any opinions would be appreciated,
-Camden



More information about the mapserver-users mailing list