[GIS] KML file showing wrong co-ordinates on Google Earth

decimal pointsdegrees minutes secondsgoogle earthkml

This is little snippet from the kml file now the co-ordinates are for some where in UK with Lat- 51.45 and Long - 0.0386 but when I plot this kml file on Google Earth it shows all the points in middle of ocean between Somalia and Seychelles ?

 <Placemark>
  <name>2016067</name>
  <description>   <![CDATA[   <b>03-May-16</b>    <hr>    <br>16:35<br>Tuesday<br>A320<br>FW<br>UAV UNSPECIFIED<br>A<br>LHR<br>Unknown<br>700<br>Unknown<br>Unknown<br>Unknown<br>Unknown<br>IFR<br>Unknown<br>]]> </description>
  <LookAt>
   <latitude>51.45</latitude>
   <longitude>3.888889E-02</longitude>
   <altitude>0</altitude>
   <range>0</range>
   <tilt>0</tilt>
   <heading>0</heading>
   <altitudeMode>relativeToGround</altitudeMode>
   <gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
  </LookAt>
  <styleUrl>#m_ylw-pushpin</styleUrl>
  <Point>
   <altitudeMode>relativeToGround</altitudeMode>
    <coordinates>51.45,3.888889E-02</coordinates>
  </Point>
 </Placemark>

 </Document>
</kml>

What am I doing wrong I am using VBA to generate KML file ?

Process:

I have this Position Co-ordinate: 5133N 00241W
I split them to get the Lats and Longs with appending extra zeros at then end if required and get the following values:

Latitude    Longitude
513300N      002410W

Then I convert them from DMS to decimal format using following formula

LatDec = Left(.Range("V" & i).Value, 2) + (Mid(.Range("V" & i).Value, 3, 2) / 60) + (Mid(.Range("V" & i).Value, 5, 2) / 3600)
LongDec = Left(.Range("W" & i).Value, 2) + (Mid(.Range("W" & i).Value, 3, 2) / 60) + (Mid(.Range("W" & i).Value, 5, 2) / 3600)

And they produce the right decimal co-ordinates and everything seems right but I just don't get the right plot on Google Earth.

Best Answer

The <coordinates> are in longitude,latitude order. See https://developers.google.com/kml/documentation/kmlreference#syntax_151.

So you wanted:

<coordinates>0.03888889,51.45</coordinates>

This is a pretty common mixup. Much of this stuff is done on a Cartesian plane, so think X-Y coordinates, and it'll make more sense.

Related Question