2

I'm trying to convert X/Y/Z coords to Latitude/Longitude coords so I can plot them on a Google Map, but math not being my strongest subject I'm having trouble.

Could anyone help me with the conversion? or is there a way to plot X/Y/Z directly onto Google Maps?

Thanks

Tempster102
  • 183
  • 3
  • 10
  • Reverse of this question. http://stackoverflow.com/questions/1185408/converting-from-longitude-latitude-to-cartesian-coordinates – desimusxvii Sep 11 '12 at 03:54
  • @Tempster102 can you please post some code related to this question how you get that functionality? – Rahul May 01 '19 at 13:42

1 Answers1

3
lat = asin(z / R) //Latitude
lon = atan2(y, x) //Longitube

Where R is the approx radius of earth.

Here's link to really simple & clear explaination of it.

Aman J
  • 1,825
  • 1
  • 16
  • 30
  • What measurement would the radius of the earth be in? I used '6372797.560856' which is meters but it returns NAN for the value. X: -8.85107925999806E+16 Y:4.23694439668789E+16 Z: -4.45135253464797E+160.9 – Tempster102 Sep 11 '12 at 04:15
  • @BrandonSmith unit of X,Y,Z & R should be same.(i.e Km or m Doesn't matter). – Aman J Sep 11 '12 at 04:21
  • @BrandonSmith try R=6372797E-6 meters. – Aman J Sep 11 '12 at 04:25
  • Z = -5.05854617976782E+16 / 6372797E-6 = asin(-7.9377174257517E+15) = PHP NAN (Not a Number) – Tempster102 Sep 11 '12 at 04:36
  • @BrandonSmith Ex: 10 to the power 100 = 10^100 = 1E100. are you getting what I am trying to say? Convert those X, Y, Z, R to numbers get rid of 'E' – Aman J Sep 11 '12 at 04:41
  • No :( Sorry, math is my worst area. – Tempster102 Sep 11 '12 at 04:43
  • @BrandonSmith post values of X, Y, Z you have in your question – Aman J Sep 11 '12 at 04:47
  • X: -8.85107925999806E+16 Y:4.23694439668789E+16 Z: -4.45135253464797E+160.9 --- These values were pulled from a data dump, so this is the way the came when I imported them into my database. – Tempster102 Sep 11 '12 at 04:47
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/16520/discussion-between-amandeep-jiddewar-and-brandon-smith) – Aman J Sep 11 '12 at 04:47