0

I have these two SQL Server 2008 R2 queries:

SELECT COUNT(*) FROM OIS_NOA_Buffers WHERE geog.STIntersects(geography::Point(35.25934, -120.64432, 4326))=1;
SELECT COUNT(*) FROM OIS_NOA_Buffers WHERE geom.STIntersects(geometry::Point(35.25934, -120.64432, 4326))=1;

The first returns a 1 and the second a 0. Both geog and geom are SRID 4326.

Geog geometry was derived from Set geog = Geom.STAsText()

Why wouldn't they both return 1? (The point is under the polygons.)

2
  • I disagree - mine was a rooky mistake about mixing up lat/long and XY - the other post was about ??? - way to complex to find my mistake. Certainly from the starting point of the OP there would be no way to run a search that pointed to the referenced post.
    – rheitzman
    May 26, 2015 at 22:43
  • You're right and it's my fault. I made two errors - first I misread the question as being about making a calculation (or confused myself in searching for possible duplicates, which btw was found by searching on "geography geometry"), so I was thinking the issue was geog vs geom and the equations used. Second, I'm pretty sure I posted the wrong link when I put in my dupe question nomination. I believe the original flag was to close as off-topic due to the issue being a typo. cc @mapperz
    – Chris W
    May 27, 2015 at 21:05

1 Answer 1

2

I figured it out..

SELECT COUNT(*) FROM Parcels..OIS_NOA_Buffers WHERE geog.STIntersects(geography::Point(35.25934, -120.64432, 4326))=1;
SELECT COUNT(*) FROM Parcels..OIS_NOA_Buffers WHERE geom.STIntersects(geometry::Point(-120.64432, 35.25934, 4326))=1;

STIntersects for geography uses Lat/Long while for geometry it uses X/Y (long/lat.)

Not the answer you're looking for? Browse other questions tagged or ask your own question.