Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculating new longitude, latitude from old + n meters

I want to create 2 new longitude and 2 new latitudes based on a coordinate and a distance in meters, I want to create a nice bounding box around a certain point. It is for a part of a city and max ±1500 meters. I therefore don't think the curvature of earth has to be taken into account.

So I have 50.0452345 (x) and 4.3242234 (y) and I want to know x + 500 meters, x - 500 meters, y - 500 meters, y + 500 meters

I found many algorithms but almost all seem to deal with the distance between points.

like image 771
Benjamin Udink ten Cate Avatar asked Sep 19 '11 20:09

Benjamin Udink ten Cate


People also ask

How do you calculate total change in longitude?

Change of Longitude It is 4° since the maximum longitude is 180° (near the International Date Line). So if two longitudes in different hemispheres are added and the total is more than 180 then subtract the total from 360 to find the change of longitude.

How do you convert nautical miles to latitude?

One minute of latitude is defined as one nautical mile (1 naut. mile or 1 nm, equivalent to 1.582 km), so one degree (1°) of latitude corresponds to 60 nautical miles or approximately 111 km.


2 Answers

The number of kilometers per degree of longitude is approximately

(pi/180) * r_earth * cos(theta*pi/180) 

where theta is the latitude in degrees and r_earth is approximately 6378 km.

The number of kilometers per degree of latitude is approximately the same at all locations, approx

(pi/180) * r_earth = 111 km / degree  

So you can do:

new_latitude  = latitude  + (dy / r_earth) * (180 / pi); new_longitude = longitude + (dx / r_earth) * (180 / pi) / cos(latitude * pi/180); 

As long as dx and dy are small compared to the radius of the earth and you don't get too close to the poles.

like image 179
nibot Avatar answered Sep 21 '22 07:09

nibot


The accepted answer is perfectly right and works. I made some tweaks and turned into this:

double meters = 50;  // number of km per degree = ~111km (111.32 in google maps, but range varies    between 110.567km at the equator and 111.699km at the poles) // 1km in degree = 1 / 111.32km = 0.0089 // 1m in degree = 0.0089 / 1000 = 0.0000089 double coef = meters * 0.0000089;  double new_lat = my_lat + coef;  // pi / 180 = 0.018 double new_long = my_long + coef / Math.cos(my_lat * 0.018); 

Hope this helps too.

like image 20
Numan Karaaslan Avatar answered Sep 17 '22 07:09

Numan Karaaslan