GML to KML Files: Viewing GML document on Google Earth
Categories:
Viewing GML Documents on Google Earth: A Comprehensive Guide

Learn how to convert GML (Geography Markup Language) files to KML (Keyhole Markup Language) for seamless visualization in Google Earth, overcoming common challenges and exploring various conversion methods.
Geography Markup Language (GML) is an XML grammar for expressing geographical features. While powerful for data exchange, GML files are not directly viewable in popular geospatial applications like Google Earth. Google Earth primarily uses Keyhole Markup Language (KML) for displaying geographic data. This article will guide you through the process of converting GML to KML, enabling you to visualize your GML data within Google Earth, and discuss various tools and techniques to achieve this.
Understanding GML and KML
Before diving into conversion, it's crucial to understand the fundamental differences and purposes of GML and KML. GML is a standard for encoding geographic information, including both spatial and non-spatial properties of geographic features. It's often used for data transfer between different GIS systems. KML, on the other hand, is an XML-based language for expressing geographic annotation and visualization within internet-based earth browsers like Google Earth. KML focuses more on presentation and less on complex data modeling.
flowchart TD A[GML Data] --> B{Conversion Process} B --> C[KML Data] C --> D[Google Earth Visualization] A -- "Complex Data Model" --> B C -- "Presentation Focused" --> D
Conceptual flow from GML data to Google Earth visualization via KML conversion.
Methods for GML to KML Conversion
Several approaches can be used to convert GML to KML, ranging from dedicated GIS software to online converters and programming libraries. The best method depends on the complexity of your GML data, your technical expertise, and the volume of data you need to process.
Using GIS Software for Conversion
Professional Geographic Information System (GIS) software offers robust tools for data conversion. Applications like QGIS (open-source) and ArcGIS (commercial) provide comprehensive functionalities to handle various geospatial data formats, including GML and KML.
1. Open GML in QGIS
Launch QGIS. Go to Layer > Add Layer > Add Vector Layer...
. Browse to your GML file and add it to the project. QGIS will often prompt you to select the appropriate sub-layer if the GML contains multiple feature types.
2. Export to KML
Once the GML layer is loaded, right-click on the layer in the 'Layers' panel. Select Export > Save Features As...
. In the 'Save Vector Layer As...' dialog, choose 'Keyhole Markup Language [KML]' as the format. Specify the output file name and location. Ensure the CRS is set correctly (WGS 84 / EPSG:4326 is standard for KML).
3. Load into Google Earth
Open Google Earth (desktop or web). Go to File > Open...
(for desktop) or Project > Open
(for web) and select your newly created KML file. Your GML data should now be visible on the globe.
Programmatic Conversion with GDAL/OGR
For automated workflows or large-scale conversions, the GDAL/OGR library is an invaluable tool. OGR is the vector data part of GDAL, supporting numerous vector formats, including GML and KML. It can be used via command-line utilities or integrated into scripts using Python, C++, or other languages.
ogr2ogr -f KML output.kml input.gml
Basic GDAL/OGR command for GML to KML conversion.
ogr2ogr
command is highly versatile. You can specify coordinate transformations (-t_srs
), select specific layers (-sql
), or apply styling (-dsco NameField=name_attribute
) during the conversion process.Online Converters
For quick, one-off conversions of smaller GML files, several online tools can perform the conversion without requiring software installation. Simply upload your GML file, and the service will convert it to KML for download. Examples include MyGeodata Converter, Ogre, or various GIS-focused online utilities.