locked
Why is this geography polygon getting so distorted? RRS feed

  • Question

  • Hi folks,
        I've got a (widescreen / rectangle) bounding box which encapsulates the USA. It doesn't go over the equator.

    When i view the polygon, it's really bent. I know the earth is round and stuff but should this poly have such an exaggerated bend?

    DECLARE @BoundingBox GEOGRAPHY, 
        @TLLong DECIMAL(18, 10), 
        @TLLat DECIMAL(18, 10), 
        @BRLong DECIMAL(18, 10), 
        @BRLat DECIMAL(18, 10), 
     
    SET @TLLong = -156.796875 
    SET @TLLat = 57.468589192089325 
    SET @BRLong = -10.634765625 
    SET @BRLat = 24.287026865376436 
     
    -- Create the bounding box for the spatial query.
    -- => Top Left, Bottom Left, Bottom Right, Top Right, Top Left (to close).
     
        SET @BoundingBox = GEOGRAPHY::STGeomFromText('POLYGON((' + CONVERT(VARCHAR(18), @TLLong) + ' ' + CONVERT(VARCHAR(18), @TLLat) + ',
            ' + CONVERT(VARCHAR(18), @TLLong) + ' ' + CONVERT(VARCHAR(18), @BRLat) + ',
            ' + CONVERT(VARCHAR(18), @BRLong) + ' ' + CONVERT(VARCHAR(18), @BRLat) + ', 
            ' + CONVERT(VARCHAR(18), @BRLong) + ' ' + CONVERT(VARCHAR(18), @TLLat) + ',
            ' + CONVERT(VARCHAR(18), @TLLong) + ' ' + CONVERT(VARCHAR(18), @TLLat) + '))', 4326) 
     
     
    SELECT @BoundingBox 



    :( hmm. Any suggestions?

    -Pure Krome-
    Thursday, January 22, 2009 7:28 AM

Answers

  • Lines in the geography datatype all represent great elliptic arcs - the shortest distance between two points on the surface of an ellipsoid. 
    If what you actually want is a line that lies straight on a flat, 2-dimensional surface, then maybe you should use projected data stored using the geometry datatype (which has already accounted for the curvature of the earth in whatever projection was used).

    Or, if you want geography data that simply 'looks' like a straight line when shown on a map (e.g. in your example you want the bottom line to follow the line of 24deg latitude), then you need to add additional 'anchor' points along the route.
    e.g. rather than a line between the points at (-156,24) at (-10,24), have a line that connects the points at 
    (-156,24),(-155,24),(-154,24),(-153,24),(-152,24) ... (-11,24),(-10,24) 
    • Marked as answer by Pure Krome Friday, January 23, 2009 5:36 AM
    Thursday, January 22, 2009 12:39 PM
    Answerer

All replies

  • Looks right to me....

    Have you got a globe? Stretch a piece of string so that it spans the shortest distance between the "bottom left" and the "bottom right" points. Notice how much north of the equator the route bends?
    Now look at your results, when overlaid on the countries of the world - you should notice that the bottom line of your polygon passes over exactly the same countries as your piece of string. (of course, you can repeat this with the line at the top of the polygon too)



    The distortion caused by projection increases the larger the surface area of the earth that you are trying to represent - in this case your polygon is very large, so it is significantly distorted.
    Thursday, January 22, 2009 8:14 AM
    Answerer
  • Yep - i didn't have any world shapefiles so i couldn't show it as you did but i suspected it as much.

    So ... the question i should have asked, was, how do create a bounding-box that covers that area of the world if it didn't distort?
    -Pure Krome-
    Thursday, January 22, 2009 11:53 AM
  • Lines in the geography datatype all represent great elliptic arcs - the shortest distance between two points on the surface of an ellipsoid. 
    If what you actually want is a line that lies straight on a flat, 2-dimensional surface, then maybe you should use projected data stored using the geometry datatype (which has already accounted for the curvature of the earth in whatever projection was used).

    Or, if you want geography data that simply 'looks' like a straight line when shown on a map (e.g. in your example you want the bottom line to follow the line of 24deg latitude), then you need to add additional 'anchor' points along the route.
    e.g. rather than a line between the points at (-156,24) at (-10,24), have a line that connects the points at 
    (-156,24),(-155,24),(-154,24),(-153,24),(-152,24) ... (-11,24),(-10,24) 
    • Marked as answer by Pure Krome Friday, January 23, 2009 5:36 AM
    Thursday, January 22, 2009 12:39 PM
    Answerer
  • the anchor points sound like a possible way to do things :)

    i can add 10 or so extra points to the bottom and 10 or so extra points to the top. that should be too hard :)

    i'll give that a go when i get to work, tomorrow. cheers (again) !
    -Pure Krome-
    Thursday, January 22, 2009 2:16 PM