Hi Emilio,
On Nov 29, 2016, at 3:30 AM, Emilio Salazar <
esal...@gmail.com> wrote:
> Is there any way to calculate the center point of a set of Coordinates (RA, DEC)?
I had a need to do this recently for lat/lon values; you should be able to adapt the code below pretty easily. (Note the difference between radians and degrees... that always trips me up.)
Cheers,
Demitri
_________________________________________
Demitri Muna
http://muna.com
Center for Cosmology and AstroParticle Physics
& Department of Astronomy
Le Ohio State University
My Projects:
http://nightlightapp.io
http://trillianverse.org
http://scicoder.org
---
def center_geolocation(geolocations):
"""
Provide a relatively accurate center lat, lon returned as a list pair, given
a list of list pairs.
ex: in: geolocations = ((lat1,lon1), (lat2,lon2),)
out: (center_lat, center_lon)
Ref:
http://stackoverflow.com/questions/6671183/calculate-the-center-point-of-multiple-latitude-longitude-coordinate-pairs
Source:
https://gist.github.com/amites/3718961
"""
x = 0
y = 0
z = 0
for lat, lon in geolocations:
lat = float(lat)
lon = float(lon)
x += cos(lat) * cos(lon)
y += cos(lat) * sin(lon)
z += sin(lat)
x = float(x / len(geolocations))
y = float(y / len(geolocations))
z = float(z / len(geolocations))
return (atan2(z, sqrt(x * x + y * y)), atan2(y, x))