[postgis-users] ST_NPoints for geography type?

14 views
Skip to first unread message

Phineas Jensen

unread,
Aug 3, 2021, 4:30:07 PM8/3/21
to postgi...@lists.osgeo.org
I am very new to GIS software and PostGIS in general, so please forgive
my likely ignorance.

I have a database with a geography field, which I generally use for
points, linestrings, and polygons. For one use case, I need to count the
number of points in that field of each row, but I've found the
ST_NPoints function doesn't exist for the geography type. I know
geography has fewer functions and capabilities because of the greater
complexity of the type, but it seems like ST_NPoints should work
regardless of that, because it just counts the number of vertices. Is
there a reason this function doesn't exist for geography, or is there an
alternative?

Thanks,
Phineas J.

_______________________________________________
postgis-users mailing list
postgi...@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users

Mike Taves

unread,
Aug 3, 2021, 6:24:41 PM8/3/21
to PostGIS Users Discussion
On Wed, 4 Aug 2021 at 08:30, Phineas Jensen <ph...@zayda.net> wrote:
> Is there a reason this function doesn't exist for geography, or is there an
> alternative?

The usual method is to cast the geography to geometry:

ST_NPoints(geog::geometry)
Reply all
Reply to author
Forward
0 new messages