Selecting feature types when using ogr2ogr to convert to shapefile?
Figured it out by reading the OGR SQL documentation at http://www.gdal.org/ogr/ogr_sql.html
This works, using one command and one output file per geometry type:
$ ogr2ogr -where "OGR_GEOMETRY='Point'" -f "ESRI Shapefile" transit_points.shp transit.kml
$ ogr2ogr -where "OGR_GEOMETRY='LineString'" -f "ESRI Shapefile" transit_linestrings.shp transit.kml
If the output
parameter is a directory instead of a file name, ogr2ogr will automatically convert all geometry types into separate shapefiles:
ogr2ogr out_dir d:\incoming\nhn_09AA001_1_0.gml
Unfortunately for the OP this doesn't work for KML, but it does for some of the other multiple geometry type formats like ArcInfo Coverages and GML. Posting here because this is the highest voted question on selecting geometry type.
D:\>dir /s/b converted\*.shp
D:\converted\NHN_HD_ISLAND_2.shp
D:\converted\NHN_HD_MANMADE_0.shp
...
D:\converted\NHN_TO_NAMEDFEA_0.shp
D:\converted\NHN_WORKUNIT_LIMIT_2.shp