locked
Spatial Query not working as expected. RRS feed

  • Question

  •  

    I have imported some data into a 2008 db that contains a geometry column using the EPSG: 4326 coordinate system, and have added a spatial index.

     

    When I run the following query I get 0 results:

     

    Code Snippet

    DECLARE @g geometry;
    SET @g = geometry::STPointFromText('POINT (51.3  0.3)',4326 );


    select name, geom as SRID from Local_Authorities
    with(index(local_auth_spatial))
     where GEOM.STContains(@g)=1;

     

     

     

    However if I run the following:

    Code Snippet
    select name, geom, geom.STSrid from  Local_Authorities
    where name like '%malling%'

     

     

    I recieved results back for "Tonbridge and Malling District" and the visualisation shows that the point should be inside the geometry (and that STSrid column confirms that the data is in EPSG: 4326)

     

    See image here

     

     

    Anyone have any ideas what I am doing wrong here?

     

    Kind regards,

     

    Ian

    Saturday, September 20, 2008 7:59 AM

Answers

  • Lat long, long lat .... arrggg!!

     

    Anyway I have got it fixed it should have of course been:

     

    Code Snippet

    SET @g = geometry::STPointFromText('POINT (0.3  51.3)',4326 );

     

     

     

    Cheers

     

    Ian

    Saturday, September 20, 2008 8:39 AM

All replies

  • Lat long, long lat .... arrggg!!

     

    Anyway I have got it fixed it should have of course been:

     

    Code Snippet

    SET @g = geometry::STPointFromText('POINT (0.3  51.3)',4326 );

     

     

     

    Cheers

     

    Ian

    Saturday, September 20, 2008 8:39 AM
  • Writing about Spatial Reporting? That would rock!

    Saturday, September 20, 2008 4:06 PM
    Answerer
  • IanBlackburn: Don't worry - we've all done it...

    ktegels: ¿Qué?
    Saturday, September 20, 2008 4:20 PM
    Answerer
  • If this Ian Blackburn is the one I suspect he might be, he did a fair amount of writing on InterDev, ADO and Access for the old Wrox.

    Saturday, September 20, 2008 4:29 PM
    Answerer
  • Ahhhh - that Ian Blackburn.

    I was thinking about the one who played Del Fisher in CrimeFighter. http://www.imdb.com/title/tt0481498/
    Saturday, September 20, 2008 4:44 PM
    Answerer
  • That's me!  If you need any interdev books I'l got a stck in my garage going cheap!
    Saturday, September 20, 2008 4:48 PM
  • LOL! Lucky I don't think anybody from Grant Thornton reads these forums... Smile

     

    Good to see you are still going at it. Your InterDev book saved my bacon a couple of times.

     

    Thanks,

    kt

     

    Saturday, September 20, 2008 4:52 PM
    Answerer
  • I wonder if you get recognition points for asking and answering your own question...  Wink

    -Isaac
    Saturday, September 20, 2008 11:13 PM