I am trying to create a Convex Hull or ConcaveHull as a polygon Z from a set of points Z which I am grouping by id. I tried to use ST_ConvexHull but it's returning Polygon in 2D, not in 3D.

My inputs point are LiDAR representation of tree canopies and I would like to combine them into a single canopy with Polygon Z geometry type.

The pseudo query should look something like:

 SELECT  st_3dconvexhull(st_collect(geom)) FROM points_z 
 GROUP BY canopy_id;
  • Creating a non-planar (higher dimensional) Convex Hull is a very intense operation, computatiinally, even if shell faces are already given. I doubt that PostgreSQL/PostGIS is the right place to store and analyze high density point clouds, despite the best efforts to allow for it (pgpointcloud). – geozelot Nov 30 '19 at 9:54
  • Even if I got around 200 points per polygon is it still a very intensive operation to create it? Maybe you know in pure math how to do it... then I could try to translate it to Postgres query. – Losbaltica Nov 30 '19 at 17:34

A similar issue is described in the postgis mailing list. Even though ST_CONVEXHULL supports 3d geometries, it doesn't use the third axis for calculations.

You could use the Quickhall Algorithm to generate convex hulls for 3d geometries. This algorithm also has an implementation in cgal, so could create a simple wrapper in postgis that uses the convex_hull_3 function.

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.