Calculating East/West Latitude/Longitude points that are x miles from a given GPS point

Posted on 2011-09-23
Medium Priority
Last Modified: 2012-05-12
Hello Experts,

I have a GPS point:


I want to know what the GPS point is exactly 3 miles east and west of this point.

I've use the formulae to work out the northern position (in PHP):

$lat = 51.747724;
$lng = -0.406958;

$radius_metres = ceil(3 * 1609.344);
$top_lat = $lat + $radius_metres/111111*(cos(10 * pi() / 180));

$north_lat = $top_lat;
$north_lng = $lng;

Open in new window

East point:
$left_lng = $lng - $radius_metres/111111*(cos(10 * pi() / 180));
$east = array($lat,$left_lng);

Open in new window

West point:
$right_lng = $lng + $radius_metres/111111*(cos(10 * pi() / 180));
$west = array($lat,$right_lng);

Open in new window

However, when I use an as-the-crow-files formula, the point is approximately 1.8 miles away
(and not 3 miles)

What is the best way of working out the east and west points.
The maximum distance between my GPS coordinate and these points will be 20 miles (so not a lot).

Many Thanks!
Question by:jagku
LVL 111

Expert Comment

by:Ray Paseur
ID: 36590494

Accepted Solution

nrbreen earned 2000 total points
ID: 36590940

You aren't taking account of the effect of lattitude on the width of a longitudinal degree,


$lng = -0.406958;


$longitudinal_delta_degrees =  $longitudinal_distance/(Cos($latitude_radians) * $meridional_radius * Pi() / 180 ) 

$left_lng = $lng - $longitudinal_delta_degrees ;
$east = array($lat,$left_lng);

$right_lng = $lng + $longitudinal_delta_degrees ;
$west = array($lat,$right_lng);

Open in new window


Author Closing Comment

ID: 36597713
Many Thanks!

I have realised that my formulae for north/south might not work either.
If I can't get it working - I'll post another question.

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question