Answered by:
STContains - tests failing for points INSIDE polygon

Question
-
The full details regarding this question are posted on StackOverflow at:
https://stackoverflow.com/questions/61734711/stcontains-tests-failing-for-points-inside-polygon
I have also used SSMS to verify that the polygon is valid - but there seems to be no way to show multiple geographic data objects in SSMS spatial view - for example, how do you show that a point is inside a polygon via spatial view?
Thanks in advance.
Monday, June 15, 2020 2:07 PM
Answers
-
Answered by David Browne at Microsoft, see:
Thanks
- Marked as answer by BDCoder Wednesday, June 17, 2020 1:49 AM
Wednesday, June 17, 2020 1:49 AM
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 -
Answered by David Browne at Microsoft, see:
Thanks
- 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