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">
<name>Libanius&apos; Letters, Cribiore.kml</name>
<Style id="sn_ylw-pushpin00">
<Style id="sh_ylw-pushpin2">
<StyleMap id="msn_grn-pushpin">
<Style id="sn_wht-pushpin">
        <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
<Style id="sn_grn-pushpin0">
        <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>


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

    <name>Libanius&apos; Letters, Cribiore</name>
    <description>Exported on Mon Oct 01 2012 16:11:04 GMT-0700 (PDT)</description>
    <Placemark id="18">
            <Data name="searchrename">
                <value>Antiochia ad Orontem</value>
            <Data name="en_name">
            <Data name="featuretyp">
            <Data name="pid">
            <Data name="gr_name">
                <value>Ἀντιόχεια ἡ Μεγάλη</value>
            <Data name="la_name">
            <Data name="timeperiod">
            <Data name="perseus_li">
            <Data name="wiki_link">
            <Data name="path">
            <Data name="x1">
            <Data name="y1">


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.


  • add qgis2kml: you can find it here: plugins.qgis.org/plugins/qgis2kml/version/0.2. its status is experimental, so fetching it in qgis requires to select "any status". but from the description: This plugin convert a vector file loaded into QGIS to kml with style. So this plugin seems not doe what you want
    – Kurt
    Oct 14, 2012 at 5:29
  • 1
    QGIS can open KML files and save them as shapefiles. I attempted this just now and didn't see any loss of attributes. Does this not work for you?
    – L_Holcombe
    Oct 14, 2012 at 6:46
  • Converting to a shapefile is your best bet. How much control of the original kml do you have?
    – Willy
    Oct 14, 2012 at 10:11
  • @Willy: edited original question to address the the first part of your comment. The original kml was created by someone who is a friend but knows less about this than I do -- 1st time she's created a kml file in GE and she's never used QGIS; I'm trying to help her. Oct 14, 2012 at 18:49
  • "Failed to open shapefile .shp/.shp" looks like you did not gave a filename for the output. After deleting the blanks in the first line and adding </Placemark> </Folder> </Document> </kml> to your snippet, I managed to open the file in Qgis and GE, but lost the attribute data (also in GE). No problem on saving with me.
    – AndreJ
    Oct 15, 2012 at 11:18

3 Answers 3


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).

  • To clarify structure, an ideal structure would be to have only polygons in one file, lines in another, points in a third kml file. Some key field names in kml are 'name' and 'description' If you are saving from a shapefile to kml, naming two of the attibutes 'name, description' will often help to get a successful export.
    – Willy
    Oct 14, 2012 at 10:10
  • Thx. I am a novice. I still am unsure how to post part of the file here despite your effort to provide instruction. The kml file has name, description, timestamp, begin, end, altitudeMode, tessellate, extrude, visibility, searchrename, en_name, featuretyp, pid, gr_name, la_name, timeperiod, perseus_li, wiki_link, path, x1, y1 fields. I want to keep data from description, timeperiod, perseus, wiki, and all name fields. Metadata in preferences says the only type of feature is a point. When I try to save as shape file I get Export to vector file failed Error: creation of data source failed... Oct 14, 2012 at 18:42
  • Figured out how to post a couple of snippets. Thx Oct 14, 2012 at 19:09
  • Finally got it working: OSGeo4W or the MS4W package contain a gdal version 1.9.2 with libkml. ogr2ogr kmlexport.shp -lco ENCODING=UTF-8 kmltest1.kml creates a shapefile readable by Qgis Lisboa, with correct greek letters.
    – AndreJ
    Oct 17, 2012 at 15:46

A XSLT transformation from KML to GML might solve your problem. GML attributes can be read completely by Quantum GIS. KML and GML are both XML files, so transformation should be possible.




are some older examples, but not yet knowing ExtendedData type. I guess for someone familiar with XSLT it should not be too difficult. Maybe someone at stackoverflow can help you with this.


I think I finally answered my own question. I don't know XSLT well enough to try that option, and the KML file it turns out was really messed up. I suspect that is why "save as" did not work, and the online converters didn't work.

I opened the file in Oxygen, edited out lots of extraneous information at the top and bottom of the file, and then made sure the file was well structured, with the same number of subfields or attributes (sorry, I don't know all the terminology) per data point. I then opened this new file in QGIS and it worked. I could save it as a .shp file and edit the attributes table.

It was time intensive, though. It's not an ideal strategy for a large file. I had few data points. I wonder why the Google Earth .kml file was so poorly structured.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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