[gdal-dev] LibKML driver always returns geometry (any) instead of the precise geometry type

G. Allegri giohappy at gmail.com
Mon Sep 26 03:07:18 PDT 2022


I'm using ogr2ogr to import KML/KMZ files with GDAL 3.2.2 on Debian 11,
which is built with the LibKML driver.

>From our tests we see that this driver always reports KML folders as
GeometryCollection layers, even though they only contain a single geometry
type
On the other hand the KML driver is able to tell the right geometry type
for each folder. It returns GeometryCollection only
for folders containing mixed contents.

Using the sample KML from here
https://developers.google.com/static/kml/documentation/KML_Samples.kml

$ogrinfo KML_Samples.kml -so
INFO: Open of `KML_Samples.kml'
      using driver `LIBKML' successful.
1: Placemarks
2: Styles and Markup
3: Highlighted Icon
4: Ground Overlays
5: Screen Overlays
6: Paths
7: Polygons
8: Google Campus
9: Extruded Polygon
10: Absolute and Relative

Forcing ogr to use the KML driver we get the expected geometry types:

$export OGR_SKIP="LibKML"
$ogrinfo KML_Samples.kml -so
INFO: Open of `KML_Samples.kml'
      using driver `KML' successful.
1: Placemarks (3D Point)
2: Highlighted Icon (3D Point)
3: Paths (3D Line String)
4: Google Campus (3D Polygon)
5: Extruded Polygon (3D Polygon)
6: Absolute and Relative (3D Polygon)

The documentation for the LibKML driver says "OGR will try to map
<MultiGeometry> to the more precise OGR geometry type (MultiPoint,
MultiLineString or MultiPolygon), and default to GeometryCollection in case
of mixed content." (https://gdal.org/drivers/vector/libkml.html#geometry).

This example doesn't contain folders with mixed types. Does the driver
consider mixed content globally?

Giovanni
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220926/8fcb2fa5/attachment.htm>


More information about the gdal-dev mailing list