ST_GeomFromGML — Takes as input GML representation of geometry and outputs a PostGIS geometry object


geometry ST_GeomFromGML(text geomgml);


Constructs a PostGIS ST_Geometry object from the OGC GML representation.

ST_GeomFromGML works only for GML Geometry fragments. It throws an error if you try to use it on a whole GML document.

OGC GML versions supported:

  • GML 3.2.1 Namespace

  • GML 3.1.1 Simple Features profile SF-2 (with GML 3.1.0 and 3.0.0 backward compatibility)

  • GML 2.1.2

OGC GML standards, cf:

Availability: 1.5

This function supports 3d and will not drop the z-index.

GML allow mixed dimensions (2D and 3D inside the same MultiGeometry for instance). As PostGIS geometries don't, ST_GeomFromGML convert the whole geometry to 2D if a missing Z dimension is found once.

GML support mixed SRS inside the same MultiGeometry. As PostGIS geometries don't, ST_GeomFromGML, in this case, reproject all subgeometries to the SRS root node. If no srsName attribute available for the GML root node, the function throw an error.

ST_GeomFromGML function is not pedantic about an explicit GML namespace. You could avoid to mention it explicitly for common usages. But you need it if you want to use XLink feature inside GML.


ST_GeomFromGML function not support SQL/MM curves geometries.

Examples - A single geometry with srsName

		<gml:LineString srsName="EPSG:4269">
				-71.16028,42.258729 -71.160837,42.259112 -71.161143,42.25932

Examples - XLink usage

		<gml:LineString xmlns:gml="" 
				<gml:Point gml:id="p1"><gml:pos>42.258729 -71.16028</gml:pos></gml:Point>
			<gml:pos>42.259112 -71.160837</gml:pos>
				<gml:Point xlink:type="simple" xlink:href="#p1"/>

See Also