views:

517

answers:

5

Is there a simple calculation I can do which will convert km into a value which I can add to a lat or lon float to calculate a bounding box for searches? It doesn't need to be completely accurate.

For instance: if I were given a lat/lon for London, England (51.5001524, -0.1262362) and I wanted calculate what the lat would be 25km east/west from that point, and what the lon would be 25km north/south of that point, what would I need to do to convert the 25km into a decimal to add to the values above?

I'm looking for a general rule-of-thumb, ie: 1km == +/- 0.XXX

Edit:

My original search for "lat lon" didn't return this result:

http://stackoverflow.com/questions/238260/how-to-calculate-the-bounding-box-for-a-given-lat-lng-location

The accepted answer seems adequate for my requirements.

A: 

There are 42 pages of questions returned for a search of "lat" - have you looked at any of those? http://stackoverflow.com/search?q=lat

iAn
+2  A: 

in that page there are some useful calculations..

http://www.movable-type.co.uk/scripts/latlong.html

ufukgun
+2  A: 

It depends on where you are:

http://www.zodiacal.com/tools/lat_table.php

klochner
+5  A: 

The approximate conversions are:

Latitude: 1 deg = 110.54 km

Longitude: 1 deg = 111.320*cos(latitude) km

This doesn't fully correct for the Earth's polar flattening -- for that you'd probably want a more complicated formula using the WGS84 reference ellipsoid (the model used for GPS). But the error is probably negligible for your purposes.

Source: http://en.wikipedia.org/wiki/Latitude

Jim Lewis
A: 

If you're using Java, Javascript or PHP, then there's a library that will do these calculations exactly, using some amusingly complicated (but still fast) trigonometry:

http://www.jstott.me.uk/jcoord/

skaffman