[postgis-users] count points for every polygon

Alexander Strunck A.Strunck at gmx.net
Tue Dec 1 00:58:32 PST 2009


hello

i am new to postgis and sql. my problem is that i want to count the points that are in every polygon. the polygon table contains gid, id, geom. the points table contains id, geom. 
i found in the internet this sql
> UPDATE polygon SET number_points = foo.count
> FROM (
>   SELECT polygon.name, count(point.gid) AS count
>   FROM point, polygon
>   WHERE ST_Contains(polygon.the_geom, point.the_geom)
>   GROUP BY polygon.name
> ) AS foo
> WHERE polygon.name = foo.name;

but it don´t seem to work for me.

Has anyone an idea how to make this work??

thx

alex
-- 
Endlich! Das Debüt-Album von Pop-Diva Sarah Kreuz ist da!                          
Jetzt bei GMX Musik Downloads. http://portal.gmx.net/de/go/musik01



More information about the postgis-users mailing list