[postgis-users] Query for shapes completely within a circle

Nicklas Avén nicklas.aven at jordogskog.no
Sat Feb 6 10:52:10 PST 2010


Hallo You have at least two options here. 1.instead of expand use st_buffer to make a circle and then use st_within the way you have done, something like:SELECT id, geom 
FROM geospatial 
WHERE ST_Within(geom, ST_Buffer(geomPt,radius) ) 
This is also an approximation since st_buffer defults to build the circle from 32 segments, but that can be modified to a higher number if nessecary.http://postgis.org/documentation/manual-1.5/ST_Buffer.html 2.The other approach needs the latest postgis released a few days ago. I fyou have that installed you can try the new function ST_DFullywithin.http://postgis.org/documentation/manual-1.5/ST_DFullyWithin.html In your case it would be something like:SELECT id, geom 
FROM geospatial 
WHERE ST_DFullyWithin(geom, geomPt, radius)  Hope that helps/Nicklas
2010-02-06 Jordan Thomas wrote:


Using ST_DWithin(geom, geomPt, radius) returns all geom that 'intersects' any part of the circle's area (acts like ST_Intersects). 
What I would like, however, is only those geom 'completely within the circle'. 
>For instance, if the point is Orlando, FL and the radius is 2 miles, the ST_Dwithin would return a shapes like the state Florida and the whole US; where I only want the buildings in Orlando.
This is the closest approximation I have so far: 
SELECT id, geom 
>FROM geospatial 
>WHERE ST_WITHIN(geom, ST_Expand(geometryFromText(geomPt, 4326), radius) ) 
This is much better, but it still returns some geom that are outside of the circle; specifically all geom completely within the superscribing box returned by ST_EXPAND.
Thanks for your help 
>Tom 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20100206/3f8c4018/attachment.html>


More information about the postgis-users mailing list