[postgis-users] Count Points in Polygon with Postgis
Stephen V. Mather
svm at clevelandmetroparks.com
Sat Mar 16 19:07:25 PDT 2013
Like Hugues example... . :)
[http://sig.cmparks.net/cmp-ms-90x122.png] Stephen V. Mather
GIS Manager
(216) 635-3243 (Work)
clevelandmetroparks.com<http://www.clemetparks.com>
________________________________
From: postgis-users-bounces at lists.osgeo.org [postgis-users-bounces at lists.osgeo.org] on behalf of Stephen Mather [mather.stephen at gmail.com]
Sent: Saturday, March 16, 2013 1:47 PM
To: PostGIS Users Discussion
Cc: PostGIS Users Discussion
Subject: Re: [postgis-users] Count Points in Polygon with Postgis
Try unioning with the opposite condition.
Sent from my iPod
On Mar 16, 2013, at 11:53 AM, Carsten Hogertz <carsten.hogertz at gmail.com<mailto:carsten.hogertz at gmail.com>> wrote:
I've got a simple problem: I want to count the number of points within a set of polygons.
I have a SQL already but it only gives back the gid of the polygone that actually contains points.
My tables: a polygon layer with 19.000 rows and a point layer with 450 rows.
The following SQL
select grid.gid, count(*) AS totale FROM grid, kioskdhd3 WHERE
st_contains(grid.geom,kioskdhd3.geom) GROUP BY grid.gid;
return only some 320 polygons that actually contain points. But I want all polygons returned, even thought the number of points is 0.
Of course it has to do with my WHERE-clause. Where do I have to put in my st_contains?
Thank you Carsten
_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org<mailto:postgis-users at lists.osgeo.org>
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130317/32a86c25/attachment.html>
More information about the postgis-users
mailing list