4

I have a distance in meters and ref latitude and longitude. Now I want latitude and longitude from the given ref point on x meters in four direction (south, north, east and west).

How can I get this value?

I need to write this in C#, but any pseudocode or logic guidance will be welcome.

Update:

I have a coordinates as references point from that I want to calculate distances of 5 meters in north direction keeping longitude as constant. So I want to calculate latitude at a distance of 5 meters from my reference point. Same I have to do for all 3 directions in east west direction I am keeping longitude as a constant.

Please let me know if any formula we can use for this.

Community
  • 1
  • 1
Sudarshan
  • 51
  • 1
  • 4
  • Check this site: http://www.movable-type.co.uk/scripts/latlong.html . There is solution for calculate distance between two points on earth, so it should be easly adopted to yours problem. – zgorawski Mar 01 '11 at 07:47
  • last time i make 4 or 5 application for that. atleast i use Drupal's database for lati long, the other great way is Google map api. i know it's not matter but best way is google api or use database from drupal who was free. –  Mar 01 '11 at 08:08

5 Answers5

9

How accurate does it have to be? You can often assume the earth is a sphere with a radius of 6360 km. In that case, one degree north or south is 10000/90 kilometers (that's how the meter was defined). East/West is only slightly harder, one degree east is 10000/90 km * cos(latitude).

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • 4
    +1 - Nice, easy method. Instead of 100km, I would use 111km for both calculations (see the [table in Wikipedia](http://en.wikipedia.org/wiki/Latitude#Degree_length)) – Justin Mar 01 '11 at 15:45
  • What about the middle directions (NW, SE, SW etc...)? – TheDarkLord Jun 24 '19 at 11:57
  • @TheDarkLord: Decompose into cardinal directions. 10 km NW is `10/sqrt(2)` km North and `10/sqrt(2)` km West. – MSalters Jun 24 '19 at 12:09
  • Oh right, dumb question... As for the west displacement its the same as east only with "-" right? Meaning -10000/90 km * cos(latitude) – TheDarkLord Jun 24 '19 at 12:12
2

Javascript example:

function translateCoordinates(distance, Lat,Lng, angle) {
    distanceNorth = Math.sin(angle) * distance;
    distanceEast = Math.cos(angle) * distance;
    earthRadius = 6371000;
    newLat = Lat + (distanceNorth / earthRadius) * 180 / Math.PI;
    newLon = Lng + (distanceEast / (earthRadius * Math.cos(newLat * 180 / Math.PI))) * 180 / Math.PI;

    return [newLat, newLon];
}

So you can convert it into c#

JHBonarius
  • 10,824
  • 3
  • 22
  • 41
user956584
  • 5,316
  • 3
  • 40
  • 50
1

This spreadsheet from the ordnance survey contains full conversions in vb script macro that can be converted.

It should be able to give you the new location based on degrees and time.

Reformat latitude and longitude coordinates between: Degrees, Minutes & Seconds; decimal Degrees; and Degrees & Decimal Minute formats.

John
  • 29,788
  • 18
  • 89
  • 130
0

The other way to calculate this is to convert degree to radian: Pi radian is equals to 180 degree. The simple point about radian is the length on the circle (surface of Earth) is radius * radian. Thus, 1 degree * pi / 180 * 6360Km = 110.947Km where pi = 3.14.

Latitude and longitude values move north-south and east-west respectively, so the above calculation could be mapped to those if the movement is along with their direction, otherwise sinus and cosinus functions must be used for mapping.

Rez.Net
  • 1,354
  • 2
  • 19
  • 28
0

I found an answer on StackExchange, in an article entitled Understanding terms in Length of Degree Formula. It uses the same formula found in Wikipedia's page, Earth Radius. The formula is in this C routine:

void Radii(double lat)
{
    double deg2rad = 3.141592653589793 / 180.0; // PI
    double a = 6378.1370; // radius at equator in kilometers
    double e2 = 0.0066943799901413165;
    double OneMinus_e2 = 1.0 - 0.0066943799901413165;
    double deg2radX1000 = (PI/180.0)*1000.0;

    lat *= deg2rad;
    u = 1.0-e2*sin(lat)*sin(lat);
    latmetersperdegree = (OneMinus_e2/u)*(a/sqrt(u))*deg2radX1000; 
    lonmetersperdegree = cos(lat)*(a/sqrt(u))*deg2radX1000;
}

I'm representing meters as pixels on a computer screen, with the known latitude placed on the screen at a known horizontal/vertical pixel location. I use the proportion between the known latitude and vertical pixel location to get the known latitude at that vertical pixel. I have to assume that the change of latitude degrees aren't significantly different enough to matter between the top and bottom of my screen (they used to be defined as 60 nautical miles per degree), and that the latmetersperdegree/lonmetersperdegree at that new latitude/longitude aren't significantly different from those at the known latitude. Latitude and longitude degrees can be computed from the computed vertical/horizontal pixel location using the latitude and longitude meters per degree.

Doug Cox
  • 51
  • 3