Skip to main content

OGC feature encoding

Read structured features from XML without guessing their geometry.

GML is an extensible XML grammar rather than one fixed schema. loaders.gl focuses on the feature and geometry subset used in production WFS responses and can emit features incrementally as the document arrives.

loaders.gl support​

TypeAPI
LoaderGMLLoader

The GML parsing path

Frame feature members. Normalize geometry. Preserve unknown properties.

The parser follows XML structure instead of searching text with regular expressions. Applications can supply known scalar types while retaining unrecognized application-schema content.

Input

GML feature collection or WFS response

Parse

Namespaces, feature members, and coordinate encodings

Normalize

Points, lines, polygons, and multiparts

Stream

Feature batches for large XML responses

GML is the OGC XML grammar for geographical features. loaders.gl focuses on the feature and geometry subset encountered in production WFS responses, with incremental parsing for large collections.

Detailed guide

GML grammar and parser details

The reference below covers supported geometry encodings, CRS metadata, streaming behavior, scalar type hints, and the boundary between GML and WFS.

Feature support​

CapabilitySupportNotes
GML 2 feature members✅ SupportedCommon WFS feature collection structures and geometry properties
GML 3 / 3.2 feature members✅ SupportedNamespace-prefix independent parsing
Empty feature collections✅ SupportedRecognized as collections, including terminal paging responses
WFS 2.0 counts and paging links✅ SupportedWhole-document parsing retains numberMatched, numberReturned, next, and previous; unknown totals remain unknown
Point and MultiPoint✅ SupportedGML 2 and GML 3 coordinate encodings
LineString, Curve, and multi-line geometry✅ SupportedSegment coordinates are normalized to GeoJSON-compatible lines
Polygon, Surface, and multi-polygon geometry✅ SupportedExterior and interior rings are preserved
coord / coordinates✅ SupportedLegacy GML 2 coordinate encodings
pos / posList✅ SupportedDimensional GML 3 coordinate encodings
CRS identifiers✅ PreservedsrsName is read; reprojection is not silently applied by the parser
Axis order⚠️ Service-awareWFS source logic handles known CRS axis-order rules
Streaming✅ SupportedparseInBatches emits collections as feature members arrive
Schema-aware scalar properties✅ SupportedSupply string, boolean, integer, number, date, and date-time hints
GeoJSON output✅ SupportedDefault geospatial representation
Binary and Arrow output✅ Through WFSWFSLoader converts parsed GML to standard vector outputs
Arbitrary GML application schemas⚠️ Best effortUnknown XML properties are preserved instead of guessed
Topologies, solids, and every ISO geometry primitive❌ Not supportedOutside the practical WFS feature subset

Parse a document​

The package root exports metadata-only loaders; async core APIs preload the parser automatically:

import {load} from '@loaders.gl/core';
import {GMLLoader} from '@loaders.gl/ogc/wms';

const table = await load('features.gml', GMLLoader);
console.log(table.numRows);

Stream a large response​

import {loadInBatches} from '@loaders.gl/core';
import {GMLLoader} from '@loaders.gl/ogc/wms';

for await (const batch of await loadInBatches(wfsResponse, GMLLoader)) {
consume(batch.data);
}

The streaming parser buffers incomplete XML features across network chunks and returns Arrow table batches. Each batch infers its property schema independently. Use gml.shape: 'geojson' for FeatureCollection batches. Whole-file parsing also accepts bare geometries (one Arrow row).

Preserve property types​

GML application schemas often carry scalar types that cannot be inferred safely from text. Supply known types from DescribeFeatureType or application metadata:

import {GMLLoaderWithParser} from '@loaders.gl/ogc/gml';

const table = GMLLoaderWithParser.parseTextSync(xml, {
gml: {
propertyTypes: {
population: 'integer',
active: 'boolean',
observedAt: 'date-time'
}
}
});

Unknown or untyped properties remain strings; structured XML properties are JSON-encoded in Arrow columns. Explicit gml.shape: 'geojson' retains the original structured property values. This avoids silently turning identifiers, codes, or zero-padded values into numbers.

GML and WFS​

Most applications should use WFSLoader rather than invoke GMLLoader directly. The WFS source negotiates the response format, applies paging and CRS request rules, streams GML, and converts the result to GeoJSON, binary, or Arrow output.

Boundaries​

GML is an extensible modeling language, not one fixed feature schema. loaders.gl intentionally does not claim universal GML conformance. The supported subset is designed for interoperable WFS feature ingestion; specialized domains may require an application-schema adapter.

References​