<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css"><!--P {margin-top:0;margin-bottom:0;}--></style>
</head>
<body ocsi="0" fpstyle="1" bgcolor="#FFFFFF">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Like Hugues example... .  :)<br>
<div><br>
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div class="WordSection1">
<p class="MsoNormal"><img src="http://sig.cmparks.net/cmp-ms-90x122.png" alt="http://sig.cmparks.net/cmp-ms-90x122.png" align="left" height="122" hspace="12" width="90">
<span style="font-size:14.0pt; font-family:"Arial","sans-serif"; color:#006C56">Stephen V. Mather<br>
</span><span style="font-size:11.0pt; font-family:"Arial","sans-serif"; color:#006C56">GIS Manager<br>
</span><span style="font-size:9.0pt; font-family:"Arial","sans-serif"; color:#006C56">(216) 635-3243 (Work)
</span><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"><a href="http://www.clemetparks.com" target="_blank"><span style=""><br>
clevelandmetroparks.com</span></a></span></p>
<p class="MsoNormal"></p>
<br>
<br>
<br>
</div>
</div>
<div></div>
</div>
</div>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF768997"><font color="#000000" face="Tahoma" size="2"><b>From:</b> postgis-users-bounces@lists.osgeo.org [postgis-users-bounces@lists.osgeo.org] on behalf of Stephen Mather [mather.stephen@gmail.com]<br>
<b>Sent:</b> Saturday, March 16, 2013 1:47 PM<br>
<b>To:</b> PostGIS Users Discussion<br>
<b>Cc:</b> PostGIS Users Discussion<br>
<b>Subject:</b> Re: [postgis-users] Count Points in Polygon with Postgis<br>
</font><br>
</div>
<div></div>
<div>
<div>Try unioning with the opposite condition.<br>
<br>
Sent from my iPod</div>
<div><br>
On Mar 16, 2013, at 11:53 AM, Carsten Hogertz <<a href="mailto:carsten.hogertz@gmail.com" target="_blank">carsten.hogertz@gmail.com</a>> wrote:<br>
<br>
</div>
<div></div>
<blockquote type="cite">
<div>
<div class="post-text">
<p>I've got a simple problem: I want to count the number of points within a set of polygons.</p>
<p>I have a SQL already but it only gives back the gid of the polygone that actually contains points.</p>
<p>My tables: a polygon layer with 19.000 rows and a point layer with 450 rows.</p>
<p>The following SQL </p>
<pre><code>select grid.gid, count(*) AS totale FROM grid, kioskdhd3 WHERE 
st_contains(grid.geom,kioskdhd3.geom) GROUP BY grid.gid;
</code></pre>
<p>return only some 320 polygons that actually contain points. But I want all polygons returned, even thought the number of points is 0.</p>
<p>Of course it has to do with my WHERE-clause. Where do I have to put in my st_contains?</p>
<p>Thank you Carsten</p>
</div>
</div>
</blockquote>
<blockquote type="cite">
<div><span>_______________________________________________</span><br>
<span>postgis-users mailing list</span><br>
<span><a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a></span><br>
<span><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a></span><br>
</div>
</blockquote>
</div>
</div>
</div>
</body>
</html>