locked
Latitude values must be between -90 and 90 degrees. RRS feed

  • General discussion

  • Hi All:

    I was using GEOGRAPHY::STPointFromText and ran into the following problem:

    A .NET Framework error occurred during execution of user-defined routine or aggregate "geography": 
    System.FormatException: 24201: Latitude values must be between -90 and 90 degrees.
    

    The solution was to use:

    GEOGRAPHY::Point(46.3491096496582, -92.198318481445312, 4326)
    Hope this helps.

    Phil


    P.Huhn

    • Moved by Kalman Toth Friday, June 14, 2013 1:43 PM Not t-sql
    Thursday, June 13, 2013 1:00 AM

All replies

  • The solution, as the error message implies, is really just to make sure your latitude values are between -90 and 90...

    geography::STPointFromText('POINT(-92.198318481445312 46.3491096496582)', 4326) works just fine for me. :)


    twitter: @alastaira blog: http://alastaira.wordpress.com/ | Pro Spatial with SQL Server 2012

    Monday, June 17, 2013 7:32 AM
    Answerer
  • Let's make sure that the fine point of coordinate pair order in SQL Server is well understood.

    What @P.Huhn has "discovered" is that you can define a point object in <latitude, longitude> order when using the Point() constructor method for the Geography type.  That is the preferred coordinate pair order by SQL Server for the Geography type. Note that the Point() method is NOT an OGC-based method (no ST prefix).

    @tanoshimi, on-the-other-hand, has "cleverly" turned the tables and used the OGC-based method, STPointFromText(), with reversed coordinates (longitude latitude).

    So, what is going on?  Since the OGC Simple Features for SQL specification failed to include a coordinate system in their Well-known Text (WKT) definition (as well as failing to distinguish between planar and geodetic coordinates - but that's another story) there was no way to easily distinguish between planar coordinates <x y> and spherical coordinates <latitude longitude>.  Bowing to convention (a.k.a. industry standard practice) in which spherical coordinates are mapped into planer space by specifying their coordinates in <longitude latitude> order, SQL Server adopted the OGC WKT coordinate order for OGC (ST prefix) methods for the Geography type. Thus,

    Geography::Point(46.3491096496582, -92.198318481445312, 4326)

    ...is equivalent to...

    Geography::STPointFromText('POINT(-92.198318481445312 46.3491096496582)', 4326)

    I hope this clears up any confusion.

    -Ed

    ==========================================================

    P.S. For some interesting history on this exact issue, see Paul Ramsey's blog posts:" Let's Call the Whole Thing Off..." and "They Called It Off!" at

    http://blog.cleverelephant.ca/2007_12_01_archive.html


    Ed Katibah Spatial Ed Blog

    Monday, June 17, 2013 11:49 PM
  • @Ed - Since the OP did not post the code sample that generated the error in question, we're left slightly guessing about "what's going on here". While your explanation is, on the balance of probability, correct, it could just have easily been a mistake in the placement of the decimal point of the latitude coordinate that was corrected when they retyped from STPointFromText() to use Point(). My answer simply was intended to demonstrate the correct way to use STPointFromText() for the coordinates in question - there was no "clever" reversing of coordinates (since I don't know which way round they were originally supplied anyway!)

    @P.Kuhn - @Ed's answer probably explains, but for future reference when you're reporting bugs/errors/unexpected behaviour it's helpful if you supply both the error message received and the code you ran that generated that error.



    twitter: @alastaira blog: http://alastaira.wordpress.com/ | Pro Spatial with SQL Server 2012

    Tuesday, June 18, 2013 7:50 AM
    Answerer