GML (Geography Markup Language) — OGC and ISO XML Standard for Geodata

2026-04-1510 min read
GMLOGCISO 19136XMLINSPIRECityGMLAIXM

GML (Geography Markup Language) is an XML vocabulary for describing geographic objects: points, lines, polygons, surfaces, solids, plus their attributes and metadata. Unlike GeoJSON, which is optimized for the web stack and JavaScript, GML is tuned for the XML ecosystem: XSD schemas, namespace separation, validation, extensibility via application schemas. The standard is owned by OGC and simultaneously ratified as ISO 19136 — that is, an international standard in the full legal sense. Heavy application schemas rest on GML: CityGML (3D city models), IndoorGML (indoor navigation), AIXM (ICAO aeronautical data), and the entire EU INSPIRE Directive — the mandatory geodata exchange format between national agencies of the European Union. On osm2cdr.ru gml_exporter.py uses the GDAL/OGR GML driver to transform OSM layers into a standard FeatureCollection with CRS declaration, namespace bindings, and schema reference.

Map generation of Samara city center

History: OGC 2000 → ISO 19136 (2007) → 3.3 (2010)

GML's roots reach back to 1998, when Ron Lake (founder of the Canadian company Galdos Systems) designed an XML vocabulary for geodata exchange between heterogeneous systems. Binary formats dominated at the time (Shapefile, MapInfo TAB), and every cross-vendor exchange required a custom converter. The GML idea — a shared XML vocabulary, human-readable and parseable with standard XML tools.

In 2000 OGC published GML 1.0 as a formal spec. The version was minimalistic — only base geometries (Point, LineString, Polygon). GML 2.0 (2001) added FeatureCollection, the feature properties concept, and CRS handling. GML 3.0 (2003) is already a mature standard: surfaces, solids, topology, temporal attributes, complex geometries. That was a revolution: the first time an XML format supported 3D polygonal surfaces and solid geometries (for CityGML and BIM).

In August 2007 GML 3.2.1 was ratified as ISO 19136:2007 — a formal international ISO TC 211 (Geographic Information) standard. From that moment GML became mandatory in EU government tenders: the INSPIRE Directive requires national cadastres, hydrography, transport, land use, and 30+ more themes to be published as GML. Germany, France, Italy, the Netherlands, Poland — all of them deliver INSPIRE data via WFS services returning GML.

GML 3.3 (2010) — the last minor version — added linear referencing systems, point representations of continuous functions (coverage functions), and simplified some constructions. In 2020 ISO released ISO 19136-1:2020 (Part 1: Fundamentals), codifying the base GML model without legacy baggage. In practice, two versions dominate in 2026: GML 2.1.2 (legacy WFS servers) and GML 3.2.1 (INSPIRE, CityGML 2.0/3.0).

Inside GML: FeatureCollection, Feature, geometryProperty

A GML file is XML with one root element, usually <gml:FeatureCollection> or an application-specific root (e.g. <core:CityModel> for CityGML). The file is linked to an XSD schema via the xsi:schemaLocation attribute pointing at the namespace URL and the XSD path. That lets validators (xmllint, Saxon) check file structure before processing.

FeatureCollection is a container for a spatial-object collection. Feature is a spatial object with a type (e.g. osm:Building), an identifier (gml:id), geometry, and attributes. The type is defined in the XSD schema as a complexType inheriting from gml:AbstractFeatureType. That gives GML a key feature: strong typing — each field is declared with a type (string, double, dateTime, enum), and the validator rejects inconsistent values.

GML geometries are richer than GeoJSON's or Shapefile's: - gml:Point — point - gml:LineString — polyline - gml:Polygon — polygon with exterior and interior rings - gml:MultiSurface / gml:MultiCurve / gml:MultiPoint — multi variants - gml:Surface — surface with patches (can be triangulated meshes) - gml:Solid — 3D solid (for CityGML LOD2/LOD3 buildings) - gml:CompositeCurve / gml:CompositeSurface / gml:CompositeSolid — topological composites - gml:OrientableCurve / gml:OrientableSurface — with explicit orientation

CRS at feature level. Unlike GeoJSON (where CRS must be WGS84) or Shapefile (where CRS is global to the file), GML lets you set CRS right inside each geometry via the srsName attribute. That is critical for INSPIRE: one file can hold data in a local national projection with an embedded EPSG reference.

Map generation of Nizhny Novgorod city center

Use cases: INSPIRE, CityGML, AIXM, government data

INSPIRE Directive (EU). Directive 2007/2/EC obliges all 27 EU countries to publish 34 geodata themes (cadastre, hydrography, transport, land use, addresses, buildings, elevation, etc.) via WMS/WFS services. The exchange format is GML 3.2.1 with application schemas published by the European Environment Agency. When the Paris municipality, the German cadastre (ALKIS), or the Dutch hydrographic service hands out data — it is always GML.

CityGML. An application schema on top of GML 3.2.1 for 3D city models. CityGML 2.0 (2012) defines 5 levels of detail (LOD0-LOD4): from flat footprint to a detailed model with interior. CityGML 3.0 (2021) added concept versioning and improved energy modeling. The standard powers digital-twin platforms in Berlin, Helsinki, Zurich, Singapore. Files store buildings, roads, vegetation, terrain in gml:Solid / gml:MultiSurface.

AIXM (Aeronautical Information Exchange Model). ICAO + EUROCONTROL designed AIXM 5.1 — a GML application schema for aeronautical data: aerodromes, runways, navaids, airspaces, procedures. All European AIPs (Aeronautical Information Publications) and the US FAA publish data in AIXM. It is the replacement for legacy ARINC 424.

Germany cadastre (ALKIS/ATKIS). All 16 federal states of Germany publish cadastral data as NAS (Normbasierte Austauschschnittstelle) — an application schema on top of GML 3.2.1. Files contain parcels (Flurstücke), buildings, easements with surveyor-grade attributes.

WFS GetFeature responses. OGC WFS (Web Feature Service) is an HTTP protocol for queries against a geo-DB. The default response format is GML. All enterprise GIS (ArcGIS Server, GeoServer, MapServer, Mapnik WFS) can return GML on WFS requests. That lets a single GIS server serve heterogeneous clients (QGIS desktop, ArcGIS Pro, custom Java apps) via one standard.

Strengths and weaknesses

Strengths. International standard (OGC + ISO 19136) — long-term compatibility and legal acceptance in government tenders. Strong typing via XSD — an invalid file is rejected before processing. CRS at feature level — multi-projection files are possible. Rich geometric model — surfaces, solids, composites, topology (which neither GeoJSON nor Shapefile have). Application schemas — CityGML, IndoorGML, AIXM, INSPIRE — allow domain-specific extensions without losing interoperability. Human-readable XML — you can open it in a text editor and grasp the structure. Validation tools (xmllint, Saxon) — industry standard. Supported across all major GIS: QGIS, ArcGIS, FME, GeoServer, MapServer, GDAL/OGR.

Weaknesses. Verbose — files are 5-10x larger than the GeoJSON equivalent due to XML overhead, namespaces, and schema declarations. Parsing performance — XML DOM parsing is slower than JSON.parse, especially on large files. XSD schema complexity — application schemas (CityGML, AIXM) include hundreds of XSD files with complex inheritance, scaring off junior devs. Not for web stack — browser JS frameworks are GeoJSON-optimized, GML requires server-side transformation. Version fragmentation — GML 2.1.2 vs 3.2.1 vs 3.3 — old WFS servers may emit legacy 2.1.2, modern ones require 3.2.1.

GML vs GeoJSON. GeoJSON — RFC 7946 JSON standard, web/JavaScript-optimized, no XSD schemas, WGS84-only CRS, flat structure. GML — ISO 19136 XML standard, strict typing via XSD, CRS at feature level, rich geometric model (surfaces, solids). For web — GeoJSON; for enterprise/government interchange — GML.

GML vs Shapefile. Shapefile — a 30-year-old binary ESRI format, 3-8 files per dataset, max 2 GB per file, ASCII-only field names, no 3D solids. GML — single XML file, unbounded size (in theory), Unicode field names, 3D and topology support. Shapefile is easier for quick exchange; GML — for standards-compliant workflows.

Workflow in OSM2CDR

gml_exporter.py uses the GDAL/OGR GML driver to transform OSM data into standard GML:

Step 1: Loading from PostGIS. local_osm_loader.py pulls bbox data from PostGIS via WKB fast-path, applies ST_SimplifyPreserveTopology matching the detail level, hands a GeoPandas DataFrame downstream.

Step 2: Layer preparation. Each OSM layer (buildings, roads, water, green_areas, POI) becomes its own feature class in the GML output. OSM tag attributes (name, type, height, addr:*) map to feature properties.

Step 3: GDAL OGR write. ogr2ogr -f GML output.gml input.geojson or the direct Python API via ogr.GetDriverByName('GML'). Options: - FORMAT=GML3.2 — version 3.2.1 (recommended), or GML2 for legacy compatibility - SRSDIMENSION_LOC=POSLIST — dimension declared on posList (3D coords) - WRITE_FEATURE_BOUNDED_BY=YES — append gml:boundedBy to every feature - STRIP_PREFIX=NO — keep the gml: namespace prefix (for INSPIRE compliance)

Step 4: XSD schema generation. GDAL automatically generates a sidecar .xsd file with field types. For an INSPIRE-compliant export you can swap to the canonical INSPIRE XSD via the XSD option.

Step 5: CRS embedding. srsName="EPSG:4326" (WGS84) by default, or any of the 165 OSM2CDR-supported CRS via the -a_srs parameter. For INSPIRE we recommend ETRS89 (EPSG:4258) for EU data.

Validation. Optionally xmllint --schema output.xsd output.gml --noout verifies the file matches the generated schema. Useful in CI/CD pipelines for government data publishing.

Map generation of Amsterdam city center

FAQ

What's the difference between GML and CityGML? GML is the base XML grammar for geodata (Point, LineString, Polygon, Surface, Solid). CityGML is an application schema (XSD schema) built on top of GML 3.2.1 for the specific domain of 3D city models. CityGML uses gml:Solid and gml:MultiSurface as primitives but adds city concepts: Building (with BuildingPart, Door, Window, Roof), Bridge, Tunnel, CityFurniture, Vegetation. Same for AIXM, IndoorGML, INSPIRE schemas — they all sit on top of GML.

Which GML version does osm2cdr.ru export? By default — GML 3.2.1 (via GDAL FORMAT=GML3.2), which equals ISO 19136:2007 and is compatible with INSPIRE / CityGML 2.0/3.0. For integration with legacy WFS servers there is a GML 2.1.2 option (FORMAT=GML2). GML 3.3 (the latest minor) is supported by GDAL but rarely used — 3.2.1 still dominates the WFS ecosystem.

Why are GML files so large? XML verbosity with namespace prefixes, schema references, and attribute declarations gives a 5-10x overhead vs GeoJSON. For one polygonal building GeoJSON is ~150 bytes, GML ~800 bytes. The fix for bandwidth-sensitive scenarios: gzip compression (GML XML compresses 8-15x thanks to repetitive tags), or switch straight to GeoPackage for exchange or PostGIS for storage.

Can you parse GML without knowing the application schema? Basic geometric extract — yes: gml:Point/LineString/Polygon are universal and GDAL/OGR recognize them schema-free. But the semantic level (building attributes, road classifications, cadastral fields) requires application schema knowledge — otherwise you get generic property bags without typing. GDAL -oo USE_SCHEMA=YES loads XSD for typing.

Does QGIS support direct INSPIRE GML import? Yes, QGIS 3.20+ opens INSPIRE GML via the GDAL driver. For complex application schemas (CityGML, ATKIS) we recommend FME or GeoServer as intermediate transformers — they flatten complex hierarchies into plain feature tables. QGIS may struggle with deeply nested namespace inheritance.

Replacement for GML in 2026? For new projects the EU is discussing GeoPackage and GeoParquet as complementary formats for bulk data exchange (more compact, faster, native CRS). But legally the INSPIRE Directive requires GML as canonical exchange format through 2030. CityGML 3.0 (2021) also continues to be built on GML 3.2.1. So GML stays mandatory for government interchange at least for the next 5-7 years.

Conclusion

GML is the OGC and ISO XML standard for geodata with the richest geometric model among open formats: surfaces, solids, topology, composites, CRS at feature level. Critical-mass ecosystems are built on it: EU INSPIRE Directive, CityGML, AIXM, IndoorGML, NAS (Germany cadastre). On osm2cdr.ru we support GML 3.2.1 (default) and GML 2.1.2 (legacy compatibility), with automatic XSD schema generation, correct CRS embedding, and 165 projections. For government workflows, INSPIRE compliance, CityGML pipelines, and WFS server integration — this is the right choice.

Export OSM to GML →

Sources

← All articles