3

I am creating a kml file in my python script. and then opening it manually in google earth.

is there a command in python to load kml file to google earth during runtime.

balakishore nadella
  • 511
  • 3
  • 7
  • 16

1 Answers1

4

os.startfile("Path to the kml file") or webbrowser.open("Path to the kml file") both will load the kml file in google earth. However, this needs that the kml files are by default set to open with google earth.

If in case kml files are by default not set to open with google earth, os.system("Path to the GoogleEarth.exe file" + "path of the KML file") will open it in Google Earth. There are other ways also to do this task.

This link provides good solutions to open files with respective applications.

MAYANK SHARMA
  • 307
  • 1
  • 4
  • 12
  • I tried import os and then os.start file('path to kml') and it worked. Thank you! – Alex J Oct 31 '15 at 13:16
  • How do you set an argument in case KMLs aren't set to open in GE by default? – LHo Mar 15 '20 at 23:28
  • @Joe extremely sorry for the late reply. In case, if you still need a solution, you can use this command os.system("Path to the GoogleEarth.exe file" + "path of the KML file") There are other ways also to do this task. You can have a look at this https://stackoverflow.com/questions/15054434/how-can-i-open-files-in-external-programs-in-python – MAYANK SHARMA Jun 03 '21 at 09:15