2

I have a lot of KMLs that include points, lines and polygons together.

Is there a way to automatically parse them into separate shapefiles (one for point, one for line, one for polygon) in QGIS or ArcGIS?

Otherwise I have to go through and delete the other two for each file, which is time consuming.

1
  • Have you considered using a find and replace within a text editor on the KML directly (using regular expressions/ regex)? There are issues with doing things which are too complex on XML files using this process, but I'm thinking that this would be a simple process for what you are needing... It should be said that I'm not particularly familiar with KML XML and what would matter is how clearly each type of data is distinguished in this. Apr 16, 2015 at 8:59

1 Answer 1

3

ogr2ogr will (sort of) do it.

Scroll down to "How do I translate a mixed geometry file to shapefile format?"

% ogr2ogr out_point.shp mixed.kml -where 'ogr_geometry = "POINT"'
% ogr2ogr out_line.shp mixed.kml -where 'ogr_geometry = "LINESTRING"'
% ogr2ogr out_poly.shp mixed.kml -where 'ogr_geometry = "POLYGON"'

ogr2ogr converting to shapefile - how to select feature types? covers it as well.

Remember you can install this on windows using OSGEO4W.

Not the answer you're looking for? Browse other questions tagged or ask your own question.