Take the tour ×

I am working on an Android app and I have latitude and longitude of a geographic point and I would like to get coordinates of the place located from X meters (North) and Y meters (West). GeoPoint does not implement this kind of functionality so I have to find a way to do it by myself...

I made some searches but I did not find anything interesting, do you have any idea how to proceed?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

With the following method you will get the latitude and longitude to add to the original location to get to the final one. Have in mind that this only works over relatively small distances, as it is ignoring the earth curvature.

private static final float GAP_LAT_LON = 0.00005f; //aprox 5 meters
private float results[] = new float[1];

private PointF getGaps(Location initial, float distanceX, float distanceY, PointF gaps){
    Location.distanceBetween(initial.getLatitude(), initial.getLongitude(), initial.getLatitude(), initial.getLongitude() + GAP_LAT_LON, results);
    double factorX = GAP_LAT_LON / results[0];
    Location.distanceBetween(initial.getLatitude(), initial.getLongitude(), initial.getLatitude() + GAP_LAT_LON, initial.getLongitude(), results);
    double factorY = GAP_LAT_LON / results[0];
    if(gaps == null)
        gaps = new PointF();
    gaps.set((float)(distanceX * factorX), (float)(distanceY * factorY));
    return gaps;

//to use
private void teste(){
    PointF gaps = null;
    Location initial = new Location("");


    //100 meters West/East and 300 meters North/South
    getGaps(initial, 100, 300, gaps);

    //gaps.x returns x offset to add/subtract to initial latitude
    //gaps.y returns y offset to add/subtract to initial longitude

good luck

share|improve this answer
Thanks it seems to work though it is not very precise :) –  lost17 Sep 29 '12 at 20:07
You can tweak it choosing a value to GAP_LAT_LON that is closer to to values of distance that you are working with. You can also increase precision if you return the gaps as double, but you will have to define your own class as PointD (double) doesn't exist. –  Luis Sep 29 '12 at 21:15
add comment

Tricky, because the distance between two whole longitudes depends on the latitude, and the distance also depends on the altitude...

To make things simple, I'd try and guess the longitude and latitude, and check the distance between the guess and the origin point. This is easier because getting the distance between two points has already been done.

Start with one axis, and do a kind of binary search until you find the location X meters to the north. Then do the same for the other axis.

share|improve this answer
add comment

Your Answer


