Description
Spatial data represents information about the physical location and shape of geometric objects. These objects can be point locations or more complex objects such as countries/regions, roads, or lakes.
SQL Server supports two spatial data types: the geometry data type and the geography data type.
- The geometry type represents data in a Euclidean (flat) coordinate system.
- The geography type represents data in a round-earth coordinate system.
Both data types are implemented as .NET common language runtime (CLR) data types in SQL Server.
Simple types:
Collection types:
Data storage is binary, tho there are function STAsText
and STGeomFromText
that can be used to display or parse string representation, The rest of functions can be found here
Binary storage for geography is packed in format:
SRID (4 bytes) | Endianness (1 byte) | Geometry type (4 bytes) | Geometry data (variable)
All SRIDs can be found in
SELECT * FROM sys.spatial_reference_systems;
Commonly used is 4326
or WGS 84 (World Geodetic System 1984) coordinate system. It can be identified from first 4 bytes of binary data ( for instance 4326
is seen stored in spatial data column as 0xE6100000....
in little endianness).