Search code examples
pythonpngkmlgoogle-earthkmz

Generate KMZ file for Google Earth from PNG with bounding lat/long coordinates?


I have a satellite image in PNG format along with the corresponding bounding latitude/longitude coordinates. I am new to this format, but wouldn't a KMZ just be a zip containing the PNG and a KML with the bounding coordinates?

How should I proceed to convert a given PNG to a KMZ file that can be viewed in Google Earth?

I would prefer python code, but any help/language would be appreciated.


Solution

  • The KMZ file would just be a ZIP file with the KML file as doc.kml and any referenced image.

    Example KML for an ground/image overlay:

    <?xml version="1.0" encoding="UTF-8"?>
    <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
    <GroundOverlay>
        <name>25N_94E_24N_93E_JOG_1966</name>
        <Icon>
            <href>25N_94E_24N_93E_JOG_1966.jpg</href>
        </Icon>
        <LatLonBox>
            <north>25</north>
            <east>94</east>
            <south>24</south>
            <west>93</west>
        </LatLonBox>
    </GroundOverlay>
    </kml>
    

    The above would be in a doc.kml file with a corresponding 25N_94E_24N_93E_JOG_1966.jpg file, both the files being in the same ZIP file with the filename having an extension kmz: Contents of a sample KMZ file