Friday, 23 October 2015

postgresql - PostGIS ST_ConvexHull for cube corners not as expected


I'm new to PostGIS and am wondering whether ST_ConvexHull will be of use in a particular work problem. Trying out some simple cases to make sure I understand what it's doing, I didn't expect this:


=> select st_astext(st_convexhull(st_geomfromtext('MULTIPOINT(0 0 0, 1 0 0, 0 1 0, 1 1 0, 0 0 1, 1 0 1, 0 1 1, 1 1 1)')));                                                                        
st_astext
---------------------------------------------
POLYGON Z ((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0))
(1 row)

I think I'm asking for the convex hull of the vertices of the unit cube, which should also be the unit cube. Have I messed up the query, or my interpretation of the result, or my understanding of convex hulls, or something in my PostGIS setup?



PostGIS 2.1.1, PostgreSQL 9.3.4.



Answer



The ST_ConvexHull function is implementing the Simple Features specification portal.opengeospatial.org/files/?artifact_id=13228 which says that "simple features are based on 2D geometry with linear interpolation between vertices". Therefore you get a flat polygon as a result.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...