Constructing geometry Instances
Collapse the table of content
Expand the table of content

Constructing geometry Instances

You can construct instances of the geometry spatial data type by inputting data either in Well-Known Text (WKT) or Well-Known Binary (WKB) format.

The geometry data type provides several built-in methods that generate a geometry from the Open Geospatial Consortium (OGC) WKT representation. The WKT standard is a text string that allows geometry data to be exchanged in textual form.

To construct any type of geometry instance from WKT input

To construct a geometry Point instance from WKT input

To construct a geometry MultiPoint instance from WKT input

To construct a geometry LineString instance from WKT input

To construct a geometry MultiLineString instance from WKT input

To construct a geometry Polygon instance from WKT input

To construct a geometry MultiPolygon instance from WKT input

To construct a geometry GeometryCollection instance from WKT input

WKB is a binary format specified by the Open Geospatial Consortium (OGC) that permits geometry data to be exchanged between a client application and an SQL database. The following functions accept WKB input to construct geometries:

To construct any type of geometry instance from WKB input

To construct a geometry Point instance from WKB input

To construct a geometry MultiPoint instance from WKB input

To construct a geometry LineString instance from WKB input

To construct a geometry MultiLineString instance from WKB input

To construct a geometry Polygon instance from WKB input

To construct a geometry MultiPolygon instance from WKB input

To construct a geometry GeometryCollection instance from WKB input

The geometry data type provides a method that generates a geometry instance from GML, an XML representation of geometric objects. SQL Server supports a subset of GML.

To construct any type of geometry instance from GML input

GeomFromGml

You can use the following methods to return either the WKT or WKB format of a geometry instance:

To return the WKT representation of a geometry instance

STAsText

ToString

To return the WKT representation of a geometry instance including any Z and M values

STAsTextZM

To return the WKB representation of a geometry instance

STAsBinary

To return a GML representation of a geometry instance

STAsGml

Once a geometry instance is constructed, you can use the following methods to determine if it is well-formed, return the instance type, or, if it is a collection instance, return a specific geometry instance.

To return the instance type of a geometry

STGeometryType

To determine if a geometry is a given instance type

InstanceOf

To determine if a geometry instance is well-formed for its instance type

STIsValid

To convert a geometry instance to a well-formed geometry instance with an instance type

MakeValid

To return the number of geometries in a geometry collection instance

STNumGeometries

To return a specific geometry in a geometry collection instance

STGeometryN

Community Additions

ADD
Show:
© 2016 Microsoft