function latlon2xyz,location,depth,a ;location[0]=lat in radians ;location[1]=lon in radians ;depth in meters ;a=radius of earth, or if a<=0, use GRS80 if n_params() eq 1 then begin depth=0 a=0 endif else if n_params() eq 2 then a=0 if a le 0 then begin a=6378137d f=1/298.257222101d esquared=2*f-f^2 endif else esquared=0d n=a/sqrt(1-(esquared*sin(location[0])^2)) x=(n-depth)*cos(location[0])*cos(location[1]) y=(n-depth)*cos(location[0])*sin(location[1]) z=(n*(1-esquared)-depth)*sin(location[0]) return,[x,y,z] end