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:
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.
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.
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).
- 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.