0

In PostGIS (2.1.8) I use function ST_NumGeometries for nums of count geometry. This function have one argument 'geometry' type. I need this function for geography type. I looked for but I didn't find it.

  • 2
    Have you tried to cast into geometry first? You can do it on-the-fly. – user30184 Dec 8 '17 at 14:01
  • I don't understand. You mean like this? ST_NumGeometries(geog::geometry) – ondrusu Dec 8 '17 at 14:05
2

From the docs

ST_NumGeometries — If geometry is a GEOMETRYCOLLECTION (or MULTI*) return the number of geometries, for single geometries will return 1, otherwise return NULL.

So, as mentioned in the comments, simply cast first with ::geometry

SELECT ST_NumGeometries( geog::geometry )
FROM CAST( ST_Multi(ST_MakePoint(1,1)) AS geography) AS geog;

SELECT ST_NumGeometries( geog::geometry )
FROM CAST( ST_ForceCollection(ST_MakePoint(1,1)) AS geography) AS geog;
  • @ondrusu please mark as chosen if it answered your question. – Evan Carroll Dec 9 '17 at 18:43
  • I am sorry I have wrong score on Stackoverflow. – ondrusu Jan 28 '18 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.