Search code examples
javacompressionkmlgoogle-earthkmz

kmz compression for google earth images with java


Does anyone know what compression to use in Java for creating KMZ files that have images stored within them? I tried using standard Java compression (and various modes, BEST_COMPRESSION, DEFAULT_COMPRESSION, etc), but my compressed file and the kmz file always come out slightly different don't load in google earth. It seems like my png images in particular (the actual kml file seems to compress the same way).

Has anyone successfully created a kmz archive that links to local images (and gets stored in the files directory) from outside of google earth?

thanks

Jeff


Solution

  • The key to understanding this is the answer from @fraser, which is supported by this snippet from KML Developer Support:

    The only supported compression method is ZIP (PKZIP-compatible), so neither gzip nor bzip would work. KMZ files compressed with this method are fully supported by the API.

    KMZ in Google Earth API & KML Compression in a Unix environment

    Apache Commons has an archive handling library which would be handy for this: http://commons.apache.org/proper/commons-vfs/filesystems.html