0

I'm trying to use kml for rendering geo-coordinates in google maps. Unfortunately, I have some troubles with coordinates: when I insert in KML coordinates from Google maps, and then pass this KML file to google maps service, placemarks points to another place in the Earth.

Maybe I dont guess format of placemark location for KML ?

dmitrynikolaev
  • 8,994
  • 4
  • 30
  • 45
  • Maybe you switched longitude and latitude around? The order should be longitude and then latitude. – Björn Jul 15 '11 at 14:53

3 Answers3

2

Sometimes Google Maps will report coordinates in "Degrees, Minutes, Seconds" (DMS) notation, which can look like this: 37°48'21.0"N 122°27'57.6"W.

KML needs coordinates in "Decimal Degrees" (DD) notation, which would look like this: -122.466001, 37.805828. Note that KML also expects the order Longitude, Latitude, which is different from many other places, which show Latitude then Longitude.

So... if you're somehow getting your coordinates in DMS notation, then you'll need to convert to DD notation, and make sure the Lon,Lat order is correct.

Christiaan Adams
  • 1,257
  • 1
  • 7
  • 13
1

in the KML file i have the LatLng was backwards.

KML => -.709448,54.009222,0
gmaps => 54.009222,-.709448
TomDunning
  • 4,829
  • 1
  • 26
  • 33
0
  1. use pandas to read cvs into df
  2. then use simplekml to export it into lml Note: coords is (lon,lat,height) # lon, lat, optional height

example:

import simplekml

snet_kml='test.kml'

kml = simplekml.Kml()

for name,lat,lon,height in zip(snet[NAMES[0]], snet[NAMES[1]], snet[NAMES[2]],   snet[NAMES[3]]):
    kml.newpoint(name=name, coords=[(lon,lat,height)])  # lon, lat, optional height

print("*** Created {}".format(snet_kml))
print(kml.kml())
kml.save(snet_kml)
Wang3t
  • 59
  • 4