Search code examples
python-3.xgoogle-earthsimplekml

Resize or show a 2+ GB KMZ file


I'm using SimpleKML to create a list of ~600 geotagged pictures (where each pin has an image as the description. So I click one of the pins on the map and it shows the picture I took at that coordinate).

The KMZ file is roughly 1GB and doesn't seem to open in Google Earth Pro. I've been looking around online and it seems that it may be too large of a file size to open. However, I have seen that Earth is capable of showing over a million coordinates. If I don't add the images as the description, the file shrinks to ~5kb and is able to work.

How can I open the file keeping the images as the description? Is there indeed an upper limit to file size?

(Note: I'm not sure if it's a Python/programming question, or Google Earth question so for now I am assuming it's a generic Google Earth question).


Solution

  • Google Earth Pro has both 32-bit and 64-bit versions. The 32-bit version limits access to 2GB memory and A 1-2 GB KMZ file is most likely larger than 2 GB when uncompressed which exceeds the memory available to Google Earth.

    Google Earth itself can handle many GBs of data but not all at once. The only way to make that much data available to Google Earth is to have the KML file load a subset of the pictures at a time.

    If the geotagged pictures are physically separable then you could create multiple KMLs where each KML represents a region and the photos in that region. Each KML file can be referenced by a parent KML file via a NetworkLink. NetworkLink would require a Region element to specify when to load the KML file with the geotagged pictures in a given region. The Region contains a bounding box (<LatLonAltBox>) that describes an area of interest defined by geographic coordinates and altitudes. In addition, a Region contains a LOD (level of detail) extent that defines a validity range of the associated Region in terms of projected screen size in pixels.

    Your root KML would be structured like this:

    <Document>
     <NetworkLink>
      <Region>
        ...
      </Region>
      <Link>
        <href>1.kml</href>
      </Link>
     </NetworkLink>
     ...
    </Document>
    

    Getting the Regions to work takes trial and error. You can measure the "screen" pixels dimensions for Regions with this KML screen ruler.

    Here are two tutorials for working with Regions:

    Alternatively, you can create several KMZ files each with a subset of geotagged pictures. You could tie the sub KMZ files together with a parent KML file with radioFolder List style and NetworkLinks with each of the KMZ files. This allows you to select any of the sub-KMZ files with photos but only one at a time to prevent memory overload.

    <Document>
        <Style id="radioStyle">
            <ListStyle>
                <listItemType>radioFolder</listItemType>
            </ListStyle>
        </Style>
        <styleUrl>#radioStyle</styleUrl>
        <NetworkLink>
            <visibility>0</visibility>
            <Link>
                <href>1.kml</href>
            </Link>
        </NetworkLink>
        <NetworkLink>
            <visibility>0</visibility>
            <Link>
                <href>2.kml</href>
            </Link>
        </NetworkLink>
    </Document>
    

    If you want one of the KML files to be viewable by default when opened in Google Earth then change its visibility to "1" and leave the others as "0".

    The SimpleKML API supports networklinks, Regions, KMZ, etc. so it is best to experiment and try different KML output to see what works better.