What are the wellformedness/validation standards for KMZ files? - kml

I have a KMZ file which contains a KML file which in turn contains a KMZ file. I am using JTS for processing this with java. The current kml/kmz parser functionality trips up with the above use case.
Can someone please throw some light on this ?

A KMZ file is a zip archive, and should contain only one KML file at its root level (usually named "doc.kml"). If it contains more than one KML file, then Earth (or another KML renderer) will choose one KML file from the KMZ and render that one, and will ignore the others.
You could theoretically have more KML files in sub-folders in the zip, and reference them via NetworkLinks in the main KML, but I've never tried it to confirm that it works.
Since a KMZ file is a zip archive, and a KML file is an XML document, there's no way to have another KMZ file inside the KML, unless it's referenced via something like a NetworkLink.
Here is the KML documentation about KMZ files:
https://developers.google.com/kml/documentation/kmzarchives

Google Earth does not support nested KMZ files (i.e., KMZ file entries within a KMZ file) and this is most likely not supported in JTS.
A KMZ file "contained within" a KMZ file may be structured in two ways:
KMZ file referenced from within another KMZ file.
KMZ file test1.kmz includes a doc.kml with NetworkLink with reference to test2.kmz which is a separate file. The file test2.kmz is located in same "folder" as test1.kmz. Alternatively, test2.kmz could be on another web server and test1.kmz uses the absolute URL to test2.kmz.
KMZ file within KMZ file -- this is not supported in Google Earth
KMZ file includes two entries: doc.kml + test2.kmz
and doc.kml has a NetworkLink with reference to "test2.kmz"
For option #2, recommend to either move the nested KMZ file to same file location as outer KMZ file or unpack the contents of nested KMZ files and add them directly to the parent KMZ file. You may need to create a folder for each nested KMZ file and change the URL reference in the NetworkLink that references it.
In practice, an external KMZ file referenced in another KMZ file (option #1) is not common since the recommended practice of a KMZ is having a self-contained KML scene including all icons, images, overlays, sub-KML files, etc. In this manner, a KMZ file is self-contained and can be e-mailed or even displayed in an off-line KML viewer.

Related

What is the right KQL file type for png files?

This
Path:"https:/.../Shared Documents/Projects - TPM Marketing/Digital Flyers"
FileType:png
Doesn't find the .png files. I can find .ppt, .pdf, but not the image files.
What is the right file type? Is there a different way to search for image files with KQL?

How to export a project in selected size tiles in JPEG or KMZ file type using QGIS?

'Convert map to raster' processing tool doesn't work for me. It doesn't have these file formats. Saving in other formats also doesn't allow me to open it.

os.symlink and window's .lnk files are different

I am processing a big images dataset and I'm trying to reorder the files in classes, while at the same time keeping the original directory structure.
To do this, I make a second directory structure with symlinks to the files in the first one.
Everything works as it should but for one small detail: the symlinks created via os.symlink() do not show the image thumbnail, while if I make a link of the same file (e.g., via right click & send to Desktop) I do see the thumbnail.
I wanted to check how the two link files differ (note, the link files themselves, not the linked file), but if I try to drag the os.symlink-generated file in a text editor it opens the linked file instead (while this does not happen with the .lnk file generated via right-click).
What's the difference between the link files? Is os.symlink making something different than a .lnk file? If so, is there a way to get the thumbnail? And if there's no such way, how can I make a .lnk file instead?

KMZ displayed incorrectly after Save to My Places and restarting Google Earth

I have several KMZ files (for example see https://www.dropbox.com/s/60pk3xx82ydwwml/RiveraAndresRecent_glacier_variations_S0895981113000382_2.kmz). When I open one of these KMZ files in Google Earth everything looks fine. However when I select "Save to My Places" by right clicking the file in the Temporary Places panel and restart Google Earth, the KMZ file is displayed incorrectly. I see several red crosses instead of the image. I suppose the networklinks in my KML file are somehow incorrect - the related image files cannot be located anymore by the KML. Is there a way to solve this, so that I can save my KMZ-files correctly to My Places?
There is a bug in Google Earth with respect to having a KMZ with NetworkLinks whose target has referenced files being saved in the saved places file. When saved the base file path in your KMZ file is changed from the KMZ location to the location of the saved places file and the nested KML files and icons/images no longer refer to a valid file path.
A workaround is to save the KMZ in a non-temporary folder (e.g. My Documents, etc.) and create a Network Link in Google Earth to that file. From Google Earth menu, click Add/Network Link then browse to the KMZ file and click "OK". Then save to 'My Places'.
There are a some validation errors in the KML, but those errors are not contributing to the bug you're now seeing. You can get a list of the errors using KML Validator. Note the KMZ itself is too large but you can upload and just validate the doc.kml first.

Google Earth will not open links in KML that have spaces

I am creating KML files from an ArcMap layer that uses XSLT to generate an HTML popup with custom links to file folders. Some of these links have embedded spaces. When I try to open these links in Google Earth, it does nothing. I have tried encoding spaces as %20 and still GE will not open them. It opens links without spaces just fine.
Here is a link from my KML that works fine:
<a target="_blank" href="file:///C:/Land/ce">Central Wildlife District</a>
Here are a couple that don't:
<a target="_blank" href="file:///C:/Land/ce/Sites/AIKENS%20CR">AIKENS CR</a>
<a target="_blank" href="file:///C:/Land/ce/Sites/AIKENS CR">AIKENS CR</a>
I found a 6-year old problem report on Google Groups (https://groups.google.com/forum/?fromgroups#!topic/kml-support-getting-started/8PfajmyJbiY) that claimed this would be fixed soon. Is it really still a problem?
Has anyone managed to figure out a way to make links with spaces work in Google Earth KML?
Whitespace and special characters in file names and folders have created problems in GE in the past:
Bug #990: Balloon image viewer will not open when the image folder name includes a space
Bug #1014: Embedded images in KMZ files don't display if the path to the KMZ contains spaces
Bug #1126: GE6 can save but fails to load filenames with '#' in filename or path
Only real solution is to simply avoid such KML and either remove all whitespace from file names and paths or replace whitespace characters with _'s.
Of course with KML generated it's often a pain to manually do this but if you want the KML to view correctly on all platforms (Windows, Mac, Linux, Mobile, etc.) then you must eliminate any "special" characters in filenames and folders referenced by KML files included those inside KMZ files.
This is discussed in a related issue with whitespace in files within KMZ file.

Resources