title: Using geometry with srid 4326, what unit of measure does STDistance return?
body: <p>So here is my set up:</p>
  
  <p>I have a table such as:</p>
  
  <p><code>Id, Lat, Long, GeoPoint, GeomPoint</code></p>
  
  <p>both <code>GeoPoint</code> (geography) and <code>GeomPoint</code> (geometry) are set to SRID 4326</p>
  
  <p>I have the following query:</p>
  
  <pre><code>    DECLARE @radiiCollection TABLE 
        ( [ID]       INT IDENTITY(1, 1) PRIMARY KEY, 
         [Radius]   GEOMETRY, 
         [RefPoint] GEOMETRY, 
         [RefAddr]  VARCHAR(255), 
         [MinLat]   VARCHAR(255), 
         [MaxLat]   VARCHAR(255), 
         [MinLng]   VARCHAR(255), 
         [MaxLng]   VARCHAR(255)) 
  
      DECLARE @point GEOMETRY = geometry::Point(-111.84493459999999, 33.3902569, 4326) 
      DECLARE @gpoint GEOGRAPHY = geography::Point(33.3902569, -111.84493459999999, 4326);
  
      INSERT INTO @radiicollection 
                  (radius, 
                   refpoint, 
                   refaddr, 
                   maxlat, 
                   maxlng, 
                   minlat, 
                   minlng) 
      VALUES      ( @point.MakeValid().STBuffer(16093.40), 
                    @point, 
                    '10 miles of 85210', 
                    33.51734689767781, 
                    -111.6923852740045, 
                    33.26298081643247, 
                    -111.99703818130439 ) 
  
      SELECT 
        GeomPoint, 
        GeoPoint
       INTO #temp 
      FROM ( 
        SELECT row_number() OVER ( 
            PARTITION BY [ds].[ADDR], 
            [ds].[APT], 
            [ds].[ZIP] ORDER BY [ds].[IND_ID] ASC 
            ) recid1, rGeop1.geompoint, rgeop1.GeoPoint 
        FROM [r].[main] ds 
        JOIN [r].[GeoPoint] rGeoP1 
          ON rGeoP1.[UID] = ds.[UID] 
        JOIN @radiiCollection rr 
          ON GeomPoint.STWithin(rr.radius) = 1 
        WHERE 1 = 1 
          AND ( 
            ( 
              ( 
                ( 
                  try_cast(latitude AS DECIMAL(9, 1)) BETWEEN CONVERT(DECIMAL(9, 1), 33.26298081643247)
                    AND CONVERT(DECIMAL(9, 1), 33.51734689767781) 
                  AND try_cast(longitude AS DECIMAL(9, 1)) BETWEEN CONVERT(DECIMAL(9, 1), - 111.99703818130439)
                    AND CONVERT(DECIMAL(9, 1), - 111.6923852740045) 
                  ) 
                ) 
              ) 
            ) 
        ) f 
      WHERE recid1 = 1
  </code></pre>
  
  <p>So, pulling both, I then pull STDistance for both the GeoPoint and the GeomPoint like so:</p>
  
  <pre><code>select top 10 
   try_cast(GeoPoint.STDistance(@gpoint) as  float) DistanceGeo,
   try_cast(GeoMPoint.STDistance(@point.MakeValid()) as float) DistanceGeom
  from #temp
  </code></pre>
  
  <p>but what I'm getting is a little weird:</p>
  
  <pre><code>    DistanceGeo     DistanceGeom
      -----------------------------------------
      10495.1674191715    0.111544285781801
      10249.4175883919    0.100540150724826
      12307.1907929483    0.1262738924781
      11804.655587608     0.116453906202276
      10249.4175883919    0.100540150724826
      9607.03640753812    0.101614826463312
      11130.8413059431    0.100596791997409
      10249.4175883919    0.100540150724826
      6973.69243171186    0.0644901191669685
      9605.88647121359    0.0967178499759486
  </code></pre>
  
  <p>From what I understand SRID determines unit of measure for the spatial column, but obviously, since both of these are SRID 4326 that is not the case?  Any help would be appreciated. I <em>believe</em> what I'm seeing here is degrees instead of meters. Is there an easy way in SQL to convert degrees to meters? Or a way to change what unit STDistance uses for output?</p>