sql server radius intersect

  • I'm fairly experienced when using SQL but new to using the geometry features. I suspect the problem I have is fairly easy to solve but I've yet to find a solution for it.

    I have a db containing a number of boxed geographical regions that are represented by 4 lat/lon points

    I also have a single lat/lon point from which I want to do a radius search. When I do the search I want to select any of the boxed geographical regions that fall either entirely or partially within the radius search.

    As the moment the lat/lon fields are stored in a decimal filed in sql but I can change them over to the geography datatype if that make solving the problem easier

  • I'm a little rusty on my geospatial but I think they way I'd handle this is use STBuffer to create the radius polygon and then STIntersects to find the polygons that have any points within that radius.

    You'll get better performance if you use geometry types rather than geography, but then STBuffer gets funky (the units aren't meters); so, you can cast from geometry to geography while you create the buffer and then back again. If you're already planning on using geography types, then you should be good to go (if your data set is small enough, maybe performance isn't your biggest concern).

    A little googling got me this article:
    https://sqldev.wordpress.com/2010/06/24/sql-server-spatial-geometry-radius/

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply