How do I convert kilometres to degrees in Geodjango/GEOS?

Jonas picture Jonas · Mar 7, 2011 · Viewed 21.9k times · Source

I'm using the "buffer" method from the GEOS API to create a circle based on a point and a radius in GeoDjango, according to this answer: GeoDjango: How to create a circle based on point and radius

As one commenter noted, you'll have to convert the radius in km to degrees... but how? I guess it's a quick formula but it's greek to me. I'd be grateful for any pointers.

Answer

sarnold picture sarnold · Mar 7, 2011

The answer may depend upon location on earth. Near the equator, 1km is going to equal roughly 0.008 degrees (1 km / 40,000 km * 360 degrees) of latitude and longitude, but near the poles, 1km is going to equal roughly 0.008 degrees latitude, but could be many many degrees longitude. (If you're 1km away from the pole, 1km travel 'west' would bring you roughly 57 degrees of longitude west.)

But, if the API just wants degrees along a great circle as the measurement, perhaps it'd be sufficient to use (n km / 40,000 km * 360 degrees). At least, 40,000km is "good enough for me" :) more accurate numbers are available.