Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9233205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:29:49+00:00 2026-06-18T06:29:49+00:00

Environment: SQL Server 2012 I’m using an online tool, the only one I could

  • 0

Environment: SQL Server 2012
I’m using an online tool, the only one I could find so far, to plot polygons and points on the earth. http://www.birdtheme.org/useful/googletool.html
I have two tables. One stores “areas” as polygons and the other table stores points amongst other things irrelevant to my question.
For simplicity, I’ll just reduce my scenario to sql variables.

In the query below, I’m using the geography data type for well known points of interest.
I drew a polygon around Robben Island, a point in Robben Island and a point in Alcatraz.

DECLARE @robben_island geography = ('POLYGON((18.351803 -33.788421,18.382788 -33.787494,18.386736 -33.820515,18.354464 -33.822369,18.351803 -33.788421))')
DECLARE @point_in_robben_island geography= ('POINT(18.369226 -33.80554)')
DECLARE @point_in_alcatraz geography= ('POINT(-122.423401 37.827006)')

SELECT @robben_island.STContains(@point_in_robben_island)   --returns 'False', but it's not what I expected
SELECT @robben_island.STContains(@point_in_alcatraz)        --returns 'True', but it's not what I expected

This query above, if I understand it correctly, tells me that my @point_in_robben_island is not contained in @robben_island, rather my @point_in_alcatraz exists in @robben_island which as we all know, is not true.

Now when I change the data types from geography to geometry, everything works fine, but I’m afraid that if I continue using the geometry data type I might come across a few gotchas. I’m just wondering if I won’t be negatively affected by fact that geometry doesn’t quite account for earth’s curvature. touch wood.

DECLARE @robben_island geometry = ('POLYGON((18.351803 -33.788421,18.382788 -33.787494,18.386736 -33.820515,18.354464 -33.822369,18.351803 -33.788421))')
DECLARE @point_in_robben_island geometry= ('POINT(18.369226 -33.80554)')
DECLARE @point_in_alcatraz geometry= ('POINT(-122.423401 37.827006)')

SELECT @robben_island.STContains(@point_in_robben_island)   --returns 'True' as it should
SELECT @robben_island.STContains(@point_in_alcatraz)        --returns 'False' as it should

Now my question is, why does the geography data type return unexpected results while geometry works as expected? Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:29:50+00:00Added an answer on June 18, 2026 at 6:29 am

    The geography type is a little bit more restrictive than geometry. It can’t cross different hemispheres and the outer ring must be drawn counter-clockwise.

    Unfortunately (some find this a good thing), SQL Server 2012 no longer throws an error when you create the invalid geography. You need to invert the order of the points in the Roben Island geometry, like:

    DECLARE @robben_island geography = ('POLYGON((18.351803 -33.788421, 18.354464 -33.822369,18.386736 -33.820515, 18.382788 -33.787494, 18.351803 -33.788421))')
    DECLARE @point_in_robben_island geography= ('POINT(18.369226 -33.80554)')
    DECLARE @point_in_alcatraz geography= ('POINT(-122.423401 37.827006)')
    
    SELECT @robben_island.STContains(@point_in_robben_island)   --returns 'True'
    SELECT @robben_island.STContains(@point_in_alcatraz)        --returns 'False'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I work in an ASP.net/ SQL Server development environment. If my only concern is
Environment: SQL Server 2012. Primary and secondary (value) index is built on xml column.
Currently my development environment is using SQL server express 2008 r2 and VS2010 for
environment: microsoft sql server 2005, 2008 given: IF object_id('tempdb..#MyTempTable') IS NOT NULL BEGIN DROP
I have a SQL Server 2005 database hosted on a shared hosting environment. Unfortunately
Details are as follows: Environment: SSRS 2008 Server, SQL Server 2008 for database, Report
In my development environment, my SQL Server is PHILIP\SQLEXPRESS . In testing, it's ANNIE
Environment: SQL Server 2005 I have a stored proc which receives comma separated value
I am using Oracle SQL Developer in a linux environment to connect to an
My dev environment has SQL Server 2008 installed. I have an asp.net 1.1 site

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.