[GIS] KML to Shapefile using GDAL (LIBKML) – MultiGeometry data not transforming

gdalgeometrykmlogrshapefile

I am trying to convert a KML file to Shapefile using GDAL (ogr2ogr).
Regular KML files convert fine but KML files containing MultiGeometry features (eg: Geometry containing both Point and Polygon) do not get transformed.

The output is simply a blank shapefile containing no shapes or attributes.

I have tried this command:

ogr2ogr -overwrite -f "ESRI Shapefile" -where OGR_GEOMETRY='MultiGeometry' <ouputfolder> <input kml>

For an example, KML file which has MultiGeometry, you can see the us_states.kml hosted by Google.

US States KML – Google.com

Other info: I am using 'GDAL 1.10.1, released 2013/08/26' for windows.

Best Answer

Shapefiles don't support MultiGeometry or GeometryCollections, but ogr2ogr can explode them:

ogr2ogr -nlt POLYGON -explodecollections -skipfailures us_states.shp us_states.kml

-explodecollections: (starting with GDAL 1.8.0) produce one feature for each geometry in any kind of geometry collection in the source file