PostGIS:计算表中线和面的顶点数


14

我在PostGIS模式中有23个表,我需要计算其顶点数。这些表是线和面的混合体,因此意识到我需要使用ST_NPoints(geom)

所以我跑了以下查询

SELECT count(ST_NPoints(geom) FROM lines;

结果/计数等于该表中要素的数量,而不是该表中所有要素的顶点总数。

我一定想念一些东西,但无法弄清楚(必须是星期一早上;)

Answers:


27

使用查询时,您只计算表中的行数(请参见表,作为调用st_npoints的次数),您需要对每个几何返回st_npoints的结果求和

SELECT sum(ST_NPoints(geom)) FROM lines;

非常感谢,效果很好。我知道这一定很简单
tjmgis
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.