STIntersect returns nothing

1220
4
04-05-2011 01:58 AM
ArnonTsairi
New Contributor
Hi all,
I'm experimenting with spatial queries in SQL Server 2008. Created an SDE DB with GEOMETRY storage type and loaded several feature classes.
I'm trying to select features from a FC intersecting a polygon:

DECLARE @LandUse geometry 
        ='POLYGON ((169394.70008075237 1068417.1000268459 <more coordinates>))'
SELECT SOIL_ID
FROM soils
WHERE Shape.STIntersects(@LandUse)=1


The statement returns no records, although the polygon declared does intersect several features in the soils FC.
What am I doing wrong?
Thanks, Arnon
0 Kudos
4 Replies
VinceAngelo
Esri Esteemed Contributor
Microsoft's documentation states:
This method always returns null if the spatial reference IDs (SRIDs) of the geometry instances do not match.

You didn't show the SRIDs involved, but that's the most likely cause.

- V
0 Kudos
ArnonTsairi
New Contributor
The SDE_geometry_columns table shows the same SRID for both feature classes (1).
I grabbed the declared polygon by a previous select statement, but in the declaration no SRID explicitly defined. Could that be the problem? Can I specify an SRID?
Thanks!
0 Kudos
VinceAngelo
Esri Esteemed Contributor
The POLYGON constructor accepts an SRID, but the ArcSDE SRID and Microsoft SRID might
be different values.  You need to use the Microsoft SRID in the native OGC operators.
The ArcSDE sequence-generated SRID is a link to a row in the spatial reference table,
where the native SRID resides.

- V
0 Kudos
ArnonTsairi
New Contributor
Thank you Vince, indeed adding the SRID to the declared polygon fixed the problem.
0 Kudos