SQL Server Block Question

This may be a really dumb question, but ...

What units does Geography.STLength return? the official MSDN page says nothing about returned units and this blog post says STLength() returns a float indicating the length of the instance in units . Yes, that's right, he says he returns it in units .

Can someone shed light on the fact that the STLength unit is returning? Legs? Meters? Inches? Help!

+6
units-of-measurement sql sql-server tsql gis
source share
1 answer

The units are completely dependent on the spatial reference identifier (SRID) of the geography / geometry data that is used. By convention, you usually use SRID "0" for geometry types if all the data is in the same unit system.

However, usually a geography type uses SRID 4326, which is a reference identifier for an ellipsoidal latitude / longitude coordinate system known as WGS 84. When you specify the coordinates of a point in this system, it is in degrees of latitude and longitude, and not at some distance from the source. Calculations of the length and area by points in this reference frame will return completely different results from geometric calculations at points of the same point position (for a great example, see the Differences between geography and geometry here , and as for why this happens, see here ) .

So, if your data columns were created with SRID "0", the system will be defined as a single one, and you will need some metadata about the data model to define units. If they were determined using a real SRID, you can use this query:

 SELECT spatial_reference_id , well_known_text , unit_of_measure , unit_conversion_factor FROM sys.spatial_reference_systems 

to check which units the SRID represents. Most of them are in meters, but a few are in feet.

+8
source share

All Articles