<html>
<head>
        <title></title>
        
<meta name="GENERATOR" content="MSHTML 8.00.6001.18876"></meta>
        
<meta name="SKYPE_FRAMEID" content="UKSDOXEVME"></meta>
        
<meta id="skype_v3_tb_marker_id" name="SKYPE_PARSING_HAS_FINISHED" content="metacontent"></meta>
</head>

<body>
        
<div align="left">Hallo</div>
        
<div align="left"> </div>
        
<div align="left">You have at least two options here.</div>
        
<div align="left"> </div>
        
<div align="left">1.</div>
        
<div align="left">instead of expand use st_buffer to make a circle and then use st_within the way you have done, something like:</div>
        
<div align="left"><span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">SELECT id, geom</span> <br />
                <span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">FROM geospatial</span> <br />
                <span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">WHERE ST_Within(geom, ST_Buffer(geomPt,radius) )</span> <br />
                </div>
        
<div align="left">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.</div>
        
<div align="left"><a href="http://postgis.org/documentation/manual-1.5/ST_Buffer.html">http://postgis.org/documentation/manual-1.5/ST_Buffer.html</a></div>
        
<div align="left"> </div>
        
<div align="left">2.</div>
        
<div align="left">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.</div><a href="http://postgis.org/documentation/manual-1.5/ST_DFullyWithin.html">http://postgis.org/documentation/manual-1.5/ST_DFullyWithin.html</a>
        
<div align="left"> </div>
        
<div align="left">In your case it would be something like:</div>
        
<div align="left"><span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">SELECT id, geom</span> <br />
                <span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">FROM geospatial</span> <br />
                <span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">WHERE ST_DFullyWithin(geom, geomPt, radius)</span> </div>
        
<div align="left"> </div>
        
<div align="left">Hope that helps</div>
        
<div align="left">/Nicklas</div>
        
<div align="left"><br />
                2010-02-06 Jordan Thomas wrote:<br />
                <br />
                </div>
        
<p><span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">Using ST_DWithin(geom, geomPt, radius) returns all geom that 'intersects' any part of the circle's area (acts like ST_Intersects). </span></p>
        
<p><span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">What I would like, however, is only those geom 'completely within the circle'. </span><br />
                ><span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">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.</span></p>
        
<p><span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">This is the closest approximation I have so far:</span> </p>
        
<p><span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">SELECT id, geom</span> <br />
                ><span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">FROM geospatial</span> <br />
                ><span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">WHERE ST_WITHIN(geom, ST_Expand(geometryFromText(geomPt, 4326), radius) )</span> </p>
        
<p><span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">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.</span></p>
        
<p><span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">Thanks for your help</span> <br />
                ><span style="FONT-FAMILY: Verdana; COLOR: #000080; FONT-SIZE: 10pt">Tom</span> </p>
</body>
</html>