The proposed use of Google Earth to mark some places and produce simple datasets emerged as big success and was widely adopted by some of my colleagues. Actually one of them is using Google Earth pretty intensive.
So I extended my begun KML to CSV XSL stylesheet to take over Google Earth KMLs in a more convenient way. With the help of this XSL stylesheet you can transform a KML to a GML file. As input examples I took the three listings at Keyholes KML-tutorial. They cover three geometry types, so the developed XSL stylesheet should support:
- Placemarks
- Paths
- Polygons.
With the help of Marc Liyanages TestXSLT I was able to test my XSL stylesheet against Sablotron, Gnome Libxslt, Saxon and Xalan-J. You’ll need one of those (or any other) XSLT processor to transform your KML to GML.
For processing XSLT on Mac OS X you can just use Marcs application, it’s easy to use and extremely helpful for developing and testing XSLT.
An online implementation of Gnome libxslt you can find here. Just copy & paste my XSL stylesheet and your KML into the corresponding fields and hit process. Copy the result in any text editor and save it as GML. E voilà!
How to transform XML with a simple java application is described in that tutorial and based on .NET here.
As in the former KML to CSV transformation you first have to delete the KML namespace declaration before processing your KML, otherwise it won’t work:
xmlns="http://earth.google.com/kml/2.0"
If you want to get some ESRI shapefiles out of your GML you can further use ogr2ogr for instance:
ogr2ogr -f "ESRI Shapefile" myfile.shp myfile.gml
I only did some very basic testing with Quantum GIS (which opens GML directly) and ArcGIS (via ogr2ogr). Possibly it won’t work with every KML.
Suggestions will be appreciated!