I have thousands of 3D polygons scattered in space but they mostly overlap with many of their neighbors in big extent.

Is there any way how to compute volume they define effectively?

I would love to have precise volume, but some relatively good approximation will do too.

My solutions so far:

  1. v.patch() (GRASS) - so far, I was able to just patch faces and kernels, but it does not form closed 3D polygon after looong computation.

  2. ST_3DUnion() (PostGIS) - unfortunately, the function is not an aggregate function (it accepts only two simple arguments). I have wrote function calling ST_3DUnion iteratively, unioning polygons one by one. But obviously, computation is slow and basically stops on polygon 100.

  3. Substracting polygons from master volume (PostGIS) - creating one big polygon from bbox of all my polygons and then using ST_3DDifference while iteratively substracting every single polygon. What I am left with is big polygon with a hole with volume of my interest. Never tried - probably same issue as 2).

  4. Overlap with 3D point grid (PostGIS) - I could create 3D points not far away each other in such way they form regular grid which covers bbox of all polygons. Finally, I would create spatial index on this layer and count points falling inside any polygon (operator &&& and ST_3DIntesects() could help a lot). But it is extremely memory demanding and gives "only" estimation of the volume. Kinda rasterization by 3D raster.

Obviously 1), 2) and 3) are suffering from exponential increase of faces/points after processing several polygons. Maybe, there is a way which does not require so expensive operations? Especially when I am interested only in volume.

Just to explain, I am trying to implement relatively simple Local Convex Hull algorithm in 3D. I have solved 3D hulling in GRASS (see my previous question) since ST_ConvexHull() does not work in 3D.

  • Have you tried ST_3DIntersection?
    – BERA
    Apr 27, 2019 at 19:11
  • Could you please elaborate? Did you mean using ST_3DIntersection on bounding master polygon and inner polygons? Firstly, the function returns solid but not closed object therefore ST_Volume() will fail (tested on the last example from man page). Also, the function can't handle multiple object at once. I have tried to feed it with my polygons as a collection. It returns TIN so again, no volume.
    – vildead
    Apr 27, 2019 at 22:15
  • Interesting question and I feel you pain having worked with the 3D functions quite a bit, and, also, the MySQL version of ST_Union, which is also not an aggregate function. If you are trying to calculate a local convex hull (which appears to operate in 2 dimensions), can you not project the extents of your volumes onto a 2D surface and perform the local convex hull on that? Apr 29, 2019 at 10:44
  • @JohnPowell: Just to clarify, I already did compute 3D convex hulls. Those are my 3D polygons. Now I need to know how big volume they cover all together. Btw, did you mean projecting on XY, YZ, and XZ, getting points which form 2D convex hull in each of these orthogonal "projections" and use only them to create approximate 3D hulls? Nice thought...
    – vildead
    Apr 30, 2019 at 7:23
  • You could try 3d meshing programs such as Blender or Meshlab. Here's an example on creating a watertight model with Meshlab - instructables.com/…. Also look into this workflow using CloudCompare - danielgm.net/cc/forum/viewtopic.php?p=24557 Nov 17 at 14:34


Your Answer

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

Browse other questions tagged or ask your own question.