QGIS KML – Editing or Converting KML to Editable Format

kmlqgis

I'm using QGIS. I'm trying to either edit a .kml file someone else created in Google Earth or convert it to another editable format (like a .shp file). I've read the following threads without really being able to figure out what the solution is:

Is there a way to export QGIS layers to KML? (seems like this plugin doesn't exist? couldn't find it)

How to convert KML to shapefile without losing attributes using QGIS? (I tried the zonums converter mentioned in the answers section, but I lose most of the data in the original .kml file)

Converting KML to shapefile via ogr2ogr including all attributes (I'm enough of a newbie that I didn't really understand this thread)

I've also tried the kml to csv converter here http://www.gps-data-team.com/convert.php. Again, it strips most of the data, giving me only the points and names.

Edited to add: saving my .kml file as a .shp file does not work. I get the following error:
Export to vector file failed.
Error: creation of data source failed (OGR error:Failed to open shapefile .shp/.shp.
It may be corrupt or read-only file accessed in update mode.
)

Here is a snippet from the beginning of the file. I'm guessing by the comments below, it's just really poorly organized. You have these pieces with the pushpin markers:

    <?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>Libanius&apos; Letters, Cribiore.kml</name>
<open>1</open>
<Style id="sn_ylw-pushpin00">
</Style>
<Style id="sh_ylw-pushpin2">
    <IconStyle>
        <scale>1.2</scale>
    </IconStyle>
</Style>
<StyleMap id="msn_grn-pushpin">
    <Pair>
        <key>normal</key>
        <styleUrl>#sn_grn-pushpin0</styleUrl>
    </Pair>
    <Pair>
        <key>highlight</key>
        <styleUrl>#sh_grn-pushpin</styleUrl>
    </Pair>
</StyleMap>
<Style id="sn_wht-pushpin">
    <IconStyle>
        <scale>1.1</scale>
        <Icon>
            <href>http://maps.google.com/mapfiles/kml/pushpin/wht-pushpin.png</href>
        </Icon>
        <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
    </IconStyle>
</Style>
<Style id="sn_grn-pushpin0">
    <IconStyle>
        <scale>1.1</scale>
        <Icon>
            <href>http://maps.google.com/mapfiles/kml/pushpin/grn-pushpin.png</href>
        </Icon>
        <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
    </IconStyle>
</Style>

….

Then about halfway through, there's a folder tag that contains the place marks :

    <Folder>
    <name>Libanius&apos; Letters, Cribiore</name>
    <description>Exported on Mon Oct 01 2012 16:11:04 GMT-0700 (PDT)</description>
    <Placemark id="18">
        <name>Antioch</name>
        <description>Home</description>
        <styleUrl>#msn_star</styleUrl>
        <ExtendedData>
            <Data name="searchrename">
                <value>Antiochia ad Orontem</value>
            </Data>
            <Data name="en_name">
                <value>Theoupolis</value>
            </Data>
            <Data name="featuretyp">
                <value>settlement</value>
            </Data>
            <Data name="pid">
                <value>658381</value>
            </Data>
            <Data name="gr_name">
                <value>Ἀντιόχεια ἡ Μεγάλη</value>
            </Data>
            <Data name="la_name">
                <value>Theoupolis</value>
            </Data>
            <Data name="timeperiod">
                <value>AHRL</value>
            </Data>
            <Data name="perseus_li">
                <value>http://www.perseus.tufts.edu/hopper/text?doc=Perseus%3Atext%3A1999.04.0006%3Aalp</value>
            </Data>
            <Data name="wiki_link">
                <value>http://en.wikipedia.org/wiki/Antioch</value>
            </Data>
            <Data name="path">
                <value>/places/658381</value>
            </Data>
            <Data name="x1">
                <value>36.15818</value>
            </Data>
            <Data name="y1">
                <value>36.202097</value>
            </Data>
        </ExtendedData>
        <Point>
            <coordinates>36.15818,36.202097,0</coordinates>
        </Point>

…..

I tried deleting all the pushpin crap in Oxygen and then reopening the layer in QGIS. The new kml file opens, and the points are there with the data I want. Still not editable, and when I try to save as shapefile I get: "Export to vector file failed.
Error: creation of layer failed (OGR error:Failed to open Shapefile `LibaniusShapefile.shp'.
)

I think I'm not sure what a well-formed KML file should look like.

Thanks.

Best Answer

I'd recommend ogr2ogr. But your success with any method will depend on the kml file itself: kml is a hierarchical file format which can contain different geometry types with each a different set of attributes. Unless your KML file is well structured, you can not convert it to a shapefile (with one geometry and the same attributes everywhere). Perhaps you should check that first in google earth? Which format do your attributes have (extended data, xml,...)? You can post a part here for more help (ctrl copy from google earth and search for relevant bits).