5

Here is the example KML file I am using:

<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
  <name>My Golf Course Example</name>
  <Placemark>
    <name>Club house3</name>
    <visibility>1</visibility>
    <phoneNumber>554545454</phoneNumber>
    <Point>
      <coordinates>-111.956,33.5043</coordinates>
    </Point>
  </Placemark>
</Document>
</kml>

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)

nmtoken
  • 13,355
  • 5
  • 38
  • 87
Reza Hussain
  • 51
  • 1
  • 4
  • 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 06: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

1 Answers1

2

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.

MappaGnosis
  • 33,857
  • 2
  • 66
  • 129
  • 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 08:46