<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Garamond;
        panose-1:2 2 4 4 3 3 1 1 8 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=FR link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hello,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Maybe I don’t understand your problem very well but I think your query for points should work with a polygon using ST_GeomFromText (<a href="http://www.postgis.org/docs/ST_GeomFromText.html">http://www.postgis.org/docs/ST_GeomFromText.html</a>) for your input polygon or a subquery if it stored into your DB.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hugues.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>De :</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> postgis-users-bounces@lists.osgeo.org [mailto:postgis-users-bounces@lists.osgeo.org] <b>De la part de</b> Joseph Spenner<br><b>Envoyé :</b> lundi 17 novembre 2014 22:35<br><b>À :</b> PostGIS Users Discussion<br><b>Objet :</b> [postgis-users] Returning polygons if any of a polygon input points lie in the polygons<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><div id="yui_3_16_0_1_1416243138622_222098"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'>Hello, I'm trying to perform a query which will return any polygons which have any points in common with an input polygon.<o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222099"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'><o:p> </o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222100"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'>So, if I have Polygon A.<o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222101"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'>In my database, I have several other polygons stored.<o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222102"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'><o:p> </o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222103"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'>I want to submit a query with Polygon A as the input, which will return all of the polygons in my database which have any points in common with Polygon A.<o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222104"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'><o:p> </o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222105"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'>Can this be done?<o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222106"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'><br>I found this:<o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222080"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'><a href="http://postgis.net/docs/ST_Overlaps.html">http://postgis.net/docs/ST_Overlaps.html</a><o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222062"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'><o:p> </o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222197"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'>But from what I can tell, it only returns a T or F.   I need to fetch the actual polygons if T.<o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222122"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'><o:p> </o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222123"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'>I'm currently able to query with points as input:<o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222182"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'><o:p> </o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222184"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'>select zone,gid,state,name,ST_Asgeojson( geom ) from polys where ST_Intersects(ST_PointFromText('POINT(-109 42)', 4269), geom);<o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222188"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'><br><br><o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222189"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'>But now I have a need to use polygons as input.<o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222190"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'><br><br><o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222191"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'>Any help would be great.<o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222192"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'><br><br><o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222193"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'>Thanks!<o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222195"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'><o:p> </o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222329"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'>Regards,<o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222336"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'>Joseph Spenner<o:p></o:p></span></p></div><div id="yui_3_16_0_1_1416243138622_222368"><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'><o:p> </o:p></span></p></div><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Garamond","serif";color:black'><o:p> </o:p></span></p></div></div></body></html>