[gdal-dev] Determine which KML file inside a KMZ a Layer comes from?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] Determine which KML file inside a KMZ a Layer comes from?

Simon Eves
I have a KMZ which contains five KML files (not including the top-level doc.kml), most of which contains a single-digit number of layers, each with a large number (hundreds to thousands) of features.

When I open the KMZ with openGDALDataset() and then use OGRDataSource::GetLayers() (the new variant which returns a collection) I get a merged list of all the layers from all the KMLs.

I am importing the data and grouping it by layer, with a single global prefix provided by the user, but as some of the KMLs have layers which have the same name as layers in another KML, the resulting merged set of layer names may not all be unique.

Is there any way to determine which KML a particular layer came from, or to get the list of KML files and then iterate the layers for each in turn?

Also, one of those five KMLs actually has 1720 layers, each of which only contains one feature. As an aside, is this common?

Thanks in advance!

--

Simon Eves
Senior Graphics Engineer, Rendering Group
OmniSci, formerly named MapD


e: [hidden email] | c: 415.902.1996



_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Determine which KML file inside a KMZ a Layer comes from?

Even Rouault-2
Simon,

> I have a KMZ which contains five KML files (not including the top-level
> doc.kml), most of which contains a single-digit number of layers, each with
> a large number (hundreds to thousands) of features.
>
> When I open the KMZ with openGDALDataset() and then use
> OGRDataSource::GetLayers() (the new variant which returns a collection) I
> get a merged list of all the layers from all the KMLs.
>
> I am importing the data and grouping it by layer, with a single global
> prefix provided by the user, but as some of the KMLs have layers which have
> the same name as layers in another KML, the resulting merged set of layer
> names may not all be unique.
>
> Is there any way to determine which KML a particular layer came from, or to
> get the list of KML files and then iterate the layers for each in turn?

You can list the kml files with VSIReadDir("/vsizip/your.kmz"), and open each
of them individually.

>
> Also, one of those five KMLs actually has 1720 layers, each of which only
> contains one feature. As an aside, is this common?

Yes, this can happen sometimes if each feature in a KML Folder. The
hierarchical nature of KML files is sometimes hard to translate in relevant
OGR layers.

Even

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Determine which KML file inside a KMZ a Layer comes from?

Simon Eves
Even Rouault <[hidden email]> wrote:

You can list the kml files with VSIReadDir("/vsizip/your.kmz"), and open each
of them individually.

Makes sense. Thanks!
 
--

Simon Eves
Senior Graphics Engineer, Rendering Group
OmniSci, formerly named MapD


e: [hidden email] | c: 415.902.1996



_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev