-1

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 ?

geocodezip
  • 158,664
  • 13
  • 220
  • 245
ZeroGraviti
  • 1,047
  • 2
  • 12
  • 28
  • How can you have a KMZ file inside a KML file? Please provide a [mcve] that demonstrates your issue. – geocodezip May 14 '17 at 18:20
  • So, its a KMZ which contains a KML which in turn contains a KMZ (i.e., KMZ <>----> KML <>-----> KMZ). Also, this KMZ file with this structure does open in Google Earth. – ZeroGraviti May 15 '17 at 04:39
  • Google Earth does not support KMZ entries packed within a KMZ file. If so then probably want to unpack the inner KMZ and repack the outer-most KMZ file with the unpacked files from the first KMZ. You can reference a KMZ file from a KMZ if use its absolute URL. See [Nested KMZ files](http://stackoverflow.com/questions/2109555/nesting-kmz-files/12897689#12897689). Please confirm if "contained" KMZ is within the first KMZ or simply referenced externally via a networkLink. – CodeMonkey May 16 '17 at 14:02

2 Answers2

0

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

Christiaan Adams
  • 1,257
  • 1
  • 7
  • 13
0

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:

  1. 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.

  2. 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.

CodeMonkey
  • 22,825
  • 4
  • 35
  • 75