Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#6981 closed defect (fixed)

OGR can't read kml files with a namespace

Reported by: ianturton Owned by: warmerdam
Priority: normal Milestone: 2.2.2
Component: OGR_SF Version: 2.1.0
Severity: normal Keywords: kml namespace
Cc:

Description

Given the file

<?xml version="1.0"?>
<kml:kml xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
  <kml:Document id="featureCollection">
    <kml:Placemark id="fid-a4f147_15d946be5a9_-8000">
      <kml:ExtendedData/>
      <kml:Polygon>
        <kml:outerBoundaryIs>
          <kml:LinearRing>
            <kml:coordinates>-104.24667729645637,48.51427295284833
-99.7498998297599,46.83215266901255 -97.41409376594723,48.019537501776014
-92.82686070646021,46.391401091711785 -91.76677799816643,48.03450552151443
-104.24667729645637,48.51427295284833</kml:coordinates>
          </kml:LinearRing>
        </kml:outerBoundaryIs>
      </kml:Polygon>
    </kml:Placemark>
  </kml:Document>
</kml:kml>

$ ogrinfo test.kml ERROR 4: ERROR parsing kml test.kml :Invalid root element ERROR 4: ERROR parsing kml test.kml :Invalid root element FAILURE: Unable to open datasource `test.kml' with the following drivers.

While this file:

<?xml version="1.0"?>
<kml xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <Document id="featureCollection">
    <Placemark id="fid-a4f147_15d946be5a9_-8000">
      <ExtendedData/>
      <Polygon>
        <outerBoundaryIs>
          <LinearRing>
            <coordinates>-104.24667729645637,48.51427295284833
-99.7498998297599,46.83215266901255 -97.41409376594723,48.019537501776014
-92.82686070646021,46.391401091711785 -91.76677799816643,48.03450552151443
-104.24667729645637,48.51427295284833</coordinates>
          </LinearRing>
        </outerBoundaryIs>
      </Polygon>
    </Placemark>
  </Document>
</kml>

gives:

$ ogrinfo test2.kml INFO: Open of `test2.kml'

using driver `LIBKML' successful.

1: test2

GDAL 2.1.0, released 2016/04/25

Further discussion can be found at https://gis.stackexchange.com/questions/246460/problem-importing-kml-generated-with-geotools-into-qgis

Attachments (2)

test.kml (812 bytes ) - added by ianturton 7 years ago.
test2.kml (709 bytes ) - added by ianturton 7 years ago.

Download all attachments as: .zip

Change History (5)

by ianturton, 7 years ago

Attachment: test.kml added

by ianturton, 7 years ago

Attachment: test2.kml added

comment:1 by Even Rouault, 7 years ago

Resolution: fixed
Status: newclosed

In 39691:

KML / LIBKML: read documents with an explicit kml prefix (fixes #6981)

comment:2 by Even Rouault, 7 years ago

In 39692:

KML / LIBKML: read documents with an explicit kml prefix (fixes #6981)

comment:3 by Even Rouault, 7 years ago

Milestone: 2.2.2
Note: See TracTickets for help on using tickets.