Here is the example KML file I am using:

<kml xmlns="http://www.opengis.net/kml/2.2">
  <name>My Golf Course Example</name>
    <name>Club house3</name>

I have named it input3.kml.

I put it, and ogr2ogr in the same folder, then I run this command:

ogr2ogr -f "ESRI Shapefile" output3.shp input3.kml

After that, I open up Quantum GIS and add vector layer, then add output3.shp.

Then I find the output3 layer, right click and open attribute table. How come only two attributes show up? (Name and Description)

  • You have name, visibility and phonenumber in the input. So what is inside the description field in your output? – Uffe Kousgaard Feb 29 '12 at 6:51
  • There are only two fields when I view the resulting shapefile's attribute table, name and descripto. For name, it is as specified, for descripto, it is NULL – Reza Hussain Feb 29 '12 at 19:15

I believe that the driver currently only works fully one way (i.e. writing TO kml). It currently expects a Description field in the KML data and uses that for its attribute, but truncates the name to 'Descriptio' because of the shapefile's DBF field naming limitation.

However, there is a version of the KML driver in development that will do what you want (so I guess it is not included in your version of ogr). BUT, you will need to re-format your KML using ExtendedData tags to wrap your... um... extended data.

  • 2
    The LIBKML driver with ExtendedData handling is now incorporated in GDAL Version 1.9.2 onwards, OSGEO4W packages, MS4W and Qgis Master. – AndreJ Oct 18 '12 at 8:46

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.