From KML 2.1 to GML, Shapefile, whatever you like…

I have used a lot of times this method from Matt Perry for converting KML files to GML or anything readable by OGR (currently OGR can just write to KML 2.0, not read it).

Yesterday I was interested in viewing the Pleiades dataset, that can be downloaded in KML format. The mentioned method wasn’t working and gave strange results (e.g. < and > converted to &lt; and &gt;, no XML tags). It took me an hour before I noticed that the sed one-liner for getting rid of the KML namespace wasn’t working just because it was looking for 2.0 instead of 2.1, which is what I had and actually the most common version you find. This was driving the XSL parser mad.

So, just change that one character, or delete by hand the xmlns declaration in your file, letting the <kml> tag alone.

Pubblicato da

Stefano Costa

Archaeologist, I study the Late Antique and Early Medieval/Byzantine period on the northern side of the Mediterranean, focusing on pottery usage patterns. I'm also involved in open source and open knowledge communities, like OSGeo, the IOSA project and the Open Knowledge Foundation.

Rispondi