Opened 12 years ago

Closed 12 years ago

#4535 closed defect (wontfix)

KML to SHP conversion is quite dummy

Reported by: frankie Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: 1.9.0
Severity: normal Keywords:
Cc:

Description

Converting from KML to shapefile does not create a proper attribute table. KML standard could be quite articulated and provide a proper table of fields with types for each Placemark for instance. The resulting conversion outputs only Descriptions or Names.

See https://developers.google.com/kml/documentation/extendeddata?hl=it for reference.

An example:

<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
  <name>ExtendedData+SchemaData</name>
  <open>1</open>

  <!-- Declare the type "TrailHeadType" with 3 fields -->
  <Schema name="TrailHeadType" id="TrailHeadTypeId">
    <SimpleField type="string" name="TrailHeadName">
      <displayName><![CDATA[<b>Trail Head Name</b>]]></displayName>
    </SimpleField>
    <SimpleField type="double" name="TrailLength">
      <displayName><![CDATA[<i>Length in miles</i>]]></displayName>
    </SimpleField>
    <SimpleField type="int" name="ElevationGain">
      <displayName><![CDATA[<i>Change in altitude</i>]]></displayName>
    </SimpleField>
  </Schema>

  <!-- Instantiate some Placemarks extended with TrailHeadType fields -->
  <Placemark>
    <name>Easy trail</name>
    <ExtendedData>
      <SchemaData schemaUrl="#TrailHeadTypeId">
        <SimpleData name="TrailHeadName">Pi in the sky</SimpleData>
        <SimpleData name="TrailLength">3.14159</SimpleData>
        <SimpleData name="ElevationGain">10</SimpleData>
      </SchemaData>
    </ExtendedData>
    <Point>
      <coordinates>-122.000,37.002</coordinates>
    </Point>
  </Placemark>
  <Placemark>
    <name>Difficult trail</name>
    <ExtendedData>
      <SchemaData schemaUrl="#TrailHeadTypeId">
        <SimpleData name="TrailHeadName">Mount Everest</SimpleData>
        <SimpleData name="TrailLength">347.45</SimpleData>
        <SimpleData name="ElevationGain">10000</SimpleData>
      </SchemaData>
    </ExtendedData>
    <Point>
      <coordinates>-121.998,37.0078</coordinates>
    </Point>
  </Placemark>
</Document>
</kml>

The resulting attribute table:

Layer name: ExtendedData+SchemaData
Geometry: Point
Feature Count: 2
Extent: (-122.000000, 37.002000) - (-121.998000, 37.007800)
Layer SRS WKT:
GEOGCS["GCS_WGS_1984",
    DATUM["WGS_1984",
        SPHEROID["WGS_84",6378137,298.257223563]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.017453292519943295]]
Name: String (80.0)
Descriptio: String (80.0)
OGRFeature(ExtendedData+SchemaData):0
  Name (String) = Easy trail
  Descriptio (String) = (null)
  POINT (-122.0 37.002)

OGRFeature(ExtendedData+SchemaData):1
  Name (String) = Difficult trail
  Descriptio (String) = (null)
  POINT (-121.998 37.0078)

Change History (2)

comment:1 by Even Rouault, 12 years ago

Do you use the "KML" (old) driver or the "LIBKML" (new one, based on Google libkml) one ?

comment:2 by Even Rouault, 12 years ago

Resolution: wontfix
Status: newclosed

After having tested myself, I'm pretty sure you are using the old driver. I've tested with the LIBKML one and it can extract all fields.

Note: See TracTickets for help on using tickets.