locked
T-SQL Geography Area calculation Problem RRS feed

  • Question

  • Hi All,

    I am facing a problem while calculating area using T-SQL Geography.

    We have the Latitude and Longitude of the points by which we mark a land. But as per the google-map scale, it is showing wrong output.

    Here is a sample code:

    DECLARE @v_polygon_string varchar(1000);
    DECLARE @g Geography;

    SET @v_polygon_string = 'POLYGON((20.91007883158800200000 85.28366393483200000000,20.91044310896200000000 85.28391488891800000000,20.91029793445400000000 85.28422711469301000000,20.90983751668700200000 85.28408864570500000000,20.91006500145300300000 85.28365328981900000000,20.91007883158800200000 85.28366393483200000000)) ';

    SET @g = Geography::STGeomFromText(@v_polygon_string,4326);
    SELECT @g.STArea();


    ------------------------------------------------------
    Output:198.747248333937 meter Sq.    [ EXPECTED Output:  ~2545 meter Sq]
    -------------------------------------------------------
    POLYGON receives latitude and longitude pairs of the points of a polygon.

     

    Thanks

    Mayukh

    • Moved by Naomi N Thursday, November 17, 2011 4:40 PM Better experts in this forum (From:Transact-SQL)
    Thursday, November 17, 2011 7:40 AM

Answers

  • Duplicate of the post I answered at http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/10731a27-81f9-4d48-98c8-fc7f8a6f50b7
    twitter: @alastaira blog: http://alastaira.wordpress.com/
    • Marked as answer by Mayukh Roy Friday, November 18, 2011 6:35 AM
    Thursday, November 17, 2011 10:38 PM
    Answerer
  • We have the answer solved byTanoshimi here:

    http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/10731a27-81f9-4d48-98c8-fc7f8a6f50b7

     

    • Marked as answer by Mayukh Roy Friday, November 18, 2011 6:35 AM
    Friday, November 18, 2011 6:30 AM

All replies

  • Nothing looks incorrect about your basic syntax. I am not experienced in the spatial data in SQL Server, but could the SRID (4326) be incorrect? Also, you might want to be sure that your data meets any restrictions outlined by Microsoft, such as being within one hemisphere. Sorry that I could not be more help.

     

    Thursday, November 17, 2011 4:22 PM
  • May be your problem is relevant to highlighted in this article

    http://conceptdev.blogspot.com/2007/12/sql-server-2008-geography-vs-geometry.html

    ?


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog
    Thursday, November 17, 2011 4:39 PM
  • Duplicate of the post I answered at http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/10731a27-81f9-4d48-98c8-fc7f8a6f50b7
    twitter: @alastaira blog: http://alastaira.wordpress.com/
    • Marked as answer by Mayukh Roy Friday, November 18, 2011 6:35 AM
    Thursday, November 17, 2011 10:38 PM
    Answerer
  • We have the answer solved byTanoshimi here:

    http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/10731a27-81f9-4d48-98c8-fc7f8a6f50b7

     

    • Marked as answer by Mayukh Roy Friday, November 18, 2011 6:35 AM
    Friday, November 18, 2011 6:30 AM