[postgis-users] is ST_ConvexHull supposed to work like this?

Martijn Meijers b.m.meijers at tudelft.nl
Wed Mar 15 04:17:03 PDT 2017


Does 'supports 3d' not mean in this context in the documentation: the 
function does not forget about each z coordinate of the input in the end 
result, but does not take it into account inside the calculation/analysis?

It seems to me that the convex hull resulting is around the x-y 
coordinates, but for the extreme points the z-coordinate will be present 
in the result (so convex hull while looking from above ;-)

select st_astext(st_convexhull(st_geomfromtext(
'MULTIPOINTZ(
0 0 0
,1 0 0
,1 1 0
,0 1 0
,0 1 1
,2 2 1
,1 0 1
,0 0 1
)'
)));


                   st_astext
---------------------------------------------
  POLYGON Z ((0 0 0,0 1 0,2 2 1,1 0 0,0 0 0))

The z=1 for point 2,2,1 is preserved however...


Martijn


On 15-03-17 12:09, Frans Knibbe wrote:
> Hello,
>
> I am looking for a way to describe a 3D feature that has only partial 
> geometric coverage with a contiguous geometry. It seemed to me that 
> ST_ConvexHull could be helpful there. But the results are not as 
> expected. So I tried a simple test query to get the convex hull of the 
> eight corners of a cube. The expected result would be a geometry 
> describing the faces of the cube but instead I get only the bottom face:
>
> _query:_
>
> select st_astext(st_convexhull(st_geomfromtext(
> 'MULTIPOINTZ(
> 0 0 0
> ,1 0 0
> ,1 1 0
> ,0 1 0
> ,0 1 1
> ,1 1 1
> ,1 0 1
> ,0 0 1
> )'
> )));
>
> _result:_
> _
> _
> POLYGON Z ((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0))
>
> This is with PostGIS 2.2.1.
>
> The current description of ST_ConvexHull reads "The convex hull of a 
> geometry represents the minimum convex geometry that encloses all 
> geometries within the set". It also says "This function supports 3d". 
> The test result seems to contradict those statements.
>
> So is ST_ConvexHull operating as expected? If it is, could there be 
> another way to get the desired result in PostGIS?
>
> Regards,
> Frans
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users



More information about the postgis-users mailing list