locked
STContains - tests failing for points INSIDE polygon RRS feed

Answers

All replies

  • Hi BDCoder,

    Please have a try with STIntersects() which will work for geography and geometry types.

    STIntersects (geography Data Type)

    Besides, STWithin determines if one item is completely within another.  STIntersects will tell you if there is any intersection.

    Please refer below for more details:

    Find known geographic points inside a polygon

    Best regards,

    Melissa

    -------------------------------------------

    MSDN Community Support

    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to  MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Tuesday, June 16, 2020 7:07 AM
  • Hi Melissa,

    Thank-you for your reply.   I tried the following:

    SELECT lat, lon, 
           @g.STIntersects( geography::Point( lat, lon, 4326 ) ) AS STIntersects
     FROM ( VALUES ( 49.119404, -102.988586 ),
                   ( 49.004776, -102.996875 ),
                   ( 48.975416, -103.005152 )
           ) points( lat, lon )

    SQL output:

    lat         lon       STIntersects
    49.119404 -102.988586 False
    49.004776 -102.996875 False
    48.975416 -103.005152 False

    However, each of the lat/lon coordinates is INSIDE the polygon (verified by Google maps) and therefore should intersect -- but SQL is saying they do not !!

    Is this a SQL / Spatial bug?  

    Also - there seems to be no way via SSMS Spatial View to view multiple geography objects - for example, using Spatial View can I view a point inside a polygon?   I can view a single polygon or a single point, but cannot view both at the same time.





    • Edited by BDCoder Tuesday, June 16, 2020 2:08 PM
    Tuesday, June 16, 2020 2:03 PM
    • Marked as answer by BDCoder Wednesday, June 17, 2020 1:49 AM
    Wednesday, June 17, 2020 1:49 AM
  • Hi BDCoder,

    Glad to hear that you have found your answer. Thanks.

    Best regards,

    Melissa

    -------------------------------------------

    MSDN Community Support

    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to  MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, June 17, 2020 2:03 AM