Search code examples
pythonscapygoogle-earthpykml

Modify Map Layers with Python & PyKML


I am starting my first major Python/Python Scapy project and I need some guidance. I have found resources like PyKML and Google Earth COM API but I do not know which will be best used to implement my idea...

I basically want to modify points in a KML in Google Earth by using an external Python script. My desired end state is to have a live streaming feed of the changes to be displayed on Google Earth. The flow/cycle of my program would be like...

* Loaded Google Earth KML with multiple points

Data is received by my Python Script, Python Script would make changes to the visibility value of a point, Google Earth displays the points turning on and off

* Rinse and repeat...

I would like to do this without having to reopen the KML every time changes made, I want the effect of it being updated live. Sort of like a live feed by local on my computer only.

My question is: Is PyKML capable of doing this or am I completely off track?

Thank you for your help.


Solution

  • PyKML could help you do this. It allows you to create arbitrary KML documents, so anything that you can figure out how to do in KML, you can automate with PyKML. Here are a couple ideas on how to approach this:

    1. Use a Python script, PyKML, and a cron job to regularly refresh static KML files stored on a web server. Use a KML Network Link element to have Google Earth reload the KML file content on a regular interval (such as every 5 seconds).
    2. If you have a lot of content, but little of it is changing, implement the KML Updates approach to incrementally modify data.