1

I found this link Create a SqlGeography polygon-circle from a center and radius

which says it is meters. This also shows meters on my system.

SELECT * FROM sys.spatial_reference_systems where spatial_reference_id = 4326;

However, when I create a circle using this code, the resulting circle has a radius of about 27 miles when I plot it using google maps api and manually measure the distance, so something is definitely off. It should be 1/2 a meter and it's actually 27 miles.

DECLARE @g geometry;
SET @g = geometry::STGeomFromText('POINT(-88.0 44.5)', 4326);
select @g.BufferWithTolerance(.5,.01,1)

-Randy

Community
  • 1
  • 1
randy
  • 253
  • 4
  • 17
  • 1
    I think I figured it out. It is actually degrees not meters. Dividing the degrees by 60 will convert it to miles. That seems to work for me anyway. – randy Feb 03 '16 at 19:19

2 Answers2

4

If you have a look at the well_known_text col in sys.spatial_reference_systems you'll see the unit for 4326 is degrees. This is the unit used for describing the location of points etc. and distance in a planar system. The unit_of_measure column is the units used for distance between points and areas when using ellipsoidal types.

So, you're using Geometry (the SQL planar type) which uses the WKT unit. If you were to be using Geography (the SQL ellipsoidal type) then the unit_of_measure is used for distances etc.

You can see this in these examples:

Geometry

DECLARE @g geometry;
DECLARE @g2 geometry;
SET @g = geometry::STGeomFromText('POINT(-88.0 44.5)', 4326);
SET @g2 = geometry::STGeomFromText('POINT(-88.0 44.0)', 4326);
SELECT @g.STDistance(@g2)

0.5

(Distance in degrees)

Geography

DECLARE @g geography;
DECLARE @g2 geography;
SET @g = geography::STGeomFromText('POINT(-88.0 44.5)', 4326);
SET @g2 = geography::STGeomFromText('POINT(-88.0 44.0)', 4326);
SELECT @g.STDistance(@g2)

55558.5621458782

(Distance in metres)

https://msdn.microsoft.com/en-us/library/bb964711.aspx#differences

Liesel
  • 2,929
  • 2
  • 12
  • 18
2

The unit will be the same as the unit of the coordinate system i.e degrees if you use geographical coordinates, meters if you use UTM or feet if you use some of the american projections.

MortenSickel
  • 2,118
  • 4
  • 26
  • 44
  • Thanks Morten. I'd like to mark your answer as correct, but how do I know what the unit of the coordinate system is? SELECT unit_of_measure FROM sys.spatial_reference_systems where spatial_reference_id = 4326 that query return metre, but for me it seems to be using degrees not meters. – randy Feb 03 '16 at 22:33
  • YOu need to check up the details of the projection. For a given projection, the unit is always defined. – MortenSickel Feb 03 '16 at 22:35
  • 1
    Look it up on http://spatialreference.org/ - and then have a look at the wkt-representation. Well, I have to admit that it is not easy to find.... – MortenSickel Feb 03 '16 at 22:40
  • Just to elaborate a bit further: the unit of epgs 4326 cannot be meters - just think about one degree along equator or along a meridian is approx 110 kms, whereas one degree east-west at one of the poles is 0 meters... – MortenSickel Feb 03 '16 at 22:43