[postgis-users] count points of a geometry

Nicolas Ribot nicky666 at gmail.com
Wed May 16 09:12:23 PDT 2007


> i am looking for good way to count all points as a sum of all the points which are in all rows of a "the_geom"-column. geometrytype can be of the type polygon, polyline, multipolygon or multiline.
>
> i am thinking of something like
>
> select sum (NumPoints("the_geom")) FROM table WHERE  true;
>
> The Documentation of PostGIS says that NumPoints(geometry) only retrieves  the number of points of the first linestring within a geometry, so that would not be sufficient for my case.
>
> ["NumPoints(geometry) ... Find and return the number of points in the first linestring in the geometry. Return NULL if there is no linestring in the geometry."]
>
> Has anybody an idea how i can get the result?
>
>

npoints for any geometry:
select sum(npoints(the_geom)) from table where ...;

Nicolas



More information about the postgis-users mailing list