3

I've been scouring the internet for the past few hours, and I just can't seem to figure it out!

I am using QGIS 2.4.0-Chugiak.

Here are my simple steps:

1) I create a new ShapeFile (Type: Polygon) and add 3 attributes: enter image description here

2) I draw a simple polygon with 6 coordinate points and give it the following attributes: enter image description here

3) I now export the Shapefile as a KML and it gives me the following text code:

    <?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document id="root_doc">
<Schema name="test1" id="test1">
    <SimpleField name="cascade_na" type="string"></SimpleField>
    <SimpleField name="sectNumb" type="int"></SimpleField>
    <SimpleField name="Market" type="string"></SimpleField>
</Schema>
<Folder><name>test1</name>
  <Placemark>
    <Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
    <ExtendedData><SchemaData schemaUrl="#test1">
        <SimpleData name="cascade_na">test1</SimpleData>
        <SimpleData name="sectNumb">9</SimpleData>
        <SimpleData name="Market">Miami</SimpleData>
    </SchemaData></ExtendedData>
      <Polygon><altitudeMode>relativeToGround</altitudeMode><outerBoundaryIs><LinearRing><altitudeMode>relativeToGround</altitudeMode><coordinates>-73.977273863779757,40.764000085624744 -73.976720692372155,40.764083880580976 -73.976333472386827,40.763925601130516 -73.976480984762205,40.763781287185402 -73.976837473002647,40.763613696404278 -73.977390644410249,40.763674215346221 -73.977273863779757,40.764000085624744</coordinates></LinearRing></outerBoundaryIs></Polygon>
  </Placemark>
</Folder>
</Document></kml>

4) Finally I go ahead and re-import what I just exported, using "Add Vector Layer" hoping to get all the attributes back, but I get none of them!

enter image description here

I just want to get all the attributes imported.

What am I doing wrong?

3

This seems to be a long running bug in QGIS: How to convert KML to shapefile without losing attributes using QGIS?

I am pretty sure it worked some time, but QGIS 1.8 and 2.2 show the same behaviour you mention.

Add vector Layer is using OGR/GDAL in the background, and that has two drivers for kml reading (KML and LIBKML), but LIBKML is not included in OSGEO4W builds.

On the other side, ogr2ogr from gisinternals/sdk is able to read the kml file, and convert it into a valid shapefile with all attributes. They have added the LIBKML driver. The same applies for the ubuntugis unstable QGIS 2.4.0 version on Ubuntu 14.04.

There are some bug report for it: http://hub.qgis.org/issues/8273 and http://trac.osgeo.org/osgeo4w/ticket/291

  • Thanks, I had previously read both links you shared, and more. My findings agree with you, it seemed that it worked at some point, which is I was puzzled that now with the latest version it doesn't work. Why go backwards... Anyways, thanks for confirming. – princelrc85 Aug 9 '14 at 19:12
  • Strangely, the same kml file opens in QGIS 2.4.0 under Ubuntu 14.04 with all fields in the attribute table. The reason might be that ubuntugis ships with the LIBKML driver, Windows only the KML driver. – AndreJ Aug 10 '14 at 9:13
  • @jef: can you confirm this? thanks! – underdark Aug 10 '14 at 9:58
  • @underdark I'm not sure "@jef" works here unless he has left a comment on this question. – AndreJ Aug 10 '14 at 10:00
  • @AndreJoost I think I sometimes get notifications from threads I haven't commented on ... not sure if that works for everyone though. – underdark Aug 10 '14 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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