Name

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

Synopsis

geometry ST_GeomFromGML(text geomgml);

Description

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: http://www.opengeospatial.org/standards/gml:

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.

[Note]

ST_GeomFromGML function not support SQL/MM curves geometries.

Examples - A single geometry with srsName

SELECT ST_GeomFromGML('
		<gml:LineString srsName="EPSG:4269">
			<gml:coordinates>
				-71.16028,42.258729 -71.160837,42.259112 -71.161143,42.25932
			</gml:coordinates>
		</gml:LineString>');
		

Examples - XLink usage

ST_GeomFromGML('
		<gml:LineString xmlns:gml="http://www.opengis.net/gml" 
				xmlns:xlink="http://www.w3.org/1999/xlink"
				srsName="urn:ogc:def:crs:EPSG::4269">
			<gml:pointProperty>
				<gml:Point gml:id="p1"><gml:pos>42.258729 -71.16028</gml:pos></gml:Point>
			</gml:pointProperty>
			<gml:pos>42.259112 -71.160837</gml:pos>
			<gml:pointProperty>
				<gml:Point xlink:type="simple" xlink:href="#p1"/>
			</gml:pointProperty>
		</gml:LineString>'););
		

See Also

ST_AsGML

ST_GMLToSQL