Creating Spatial Data
SQL Server 2008 allows you to create items of data using three standard formats: Well-Known Text (WKT), Well-Known Binary (WKB), and Geography Markup Language (GML).
- WKT is the format you will see used most often in examples in Microsoft SQL Server Books Online and in tutorials. It is simple to understand, and relatively concise.
- WKB is a standard binary format that is an efficient way of passing spatial data between systems.
- GML is an XML-based representation that has a very explicit hierarchical structure. It is ideal for sharing spatial information over the internet.
Every format has one or more associated static methods that can be used to instantiate items of geography or geometry data from a representation supplied in that format, as shown in the following table:
| Geometry | WKT | WKB | GML |
|---|---|---|---|
| Point | STPointFromText() | STPointFromWKB() | GeomFromGml() |
| LineString | STLineFromText() | STLineFromWKB() | GeomFromGml() |
| Polygon | STPolyFromText() | STPolyFromWKB() | GeomFromGml() |
| MultiPoint | STMPointFromText() | STMPointFromWKB() | GeomFromGml() |
| MultiLineString | STMLineFromText() | STMLineFromWKB() | GeomFromGml() |
| MultiPolygon | STMPolyFromText() | STMPolyFromWKB() | GeomFromGml() |
| Geometry Collection | STGeomCollFromText() | STGeomCollFromWKB() | GeomFromGml() |
| Any Type | STGeomFromText() Parse() |
STGeomFromWKB() | GeomFromGml() |
In this chapter I discuss the advantages and disadvantages of each format, demonstrate how they can each be used to represent different types of geometry, and give you advice on choosing the appropriate format for your data.


Comments
Post new comment