×
Community Blog PostgreSQL: Processing 3D Data with PostGIS and SFCGAL

PostgreSQL: Processing 3D Data with PostGIS and SFCGAL

In this article, the author discusses how to process 3D spatial data in PostgreSQL using PostGIS and SFCGAL.

By digoal

Background

PostGIS integrates SFCGAL to process 3D spatial data gracefully.

1

2

3

Examples:

SFCGAL, a C++ wrapper library around CGAL that supports ISO 19107:2013 and OGC Simple Features Access 1.2 for 3D operations, is now an optional included in PostGIS.

This was a quiet outcome of the Boston Code Sprint after Paul Ramsey declared exact rational number representation would not make its way into PostGIS.

What does this mean for a typical PostGIS user? It adds an excellent suite of new 2D and 3D functions: http://postgis.net/docs/manual-2.4/reference.html

postgis_sfcgal_version — Returns the version of SFCGAL in use  
  
ST_Extrude — Extrude a surface to a related volume  
  
ST_StraightSkeleton — Compute a straight skeleton from a geometry  
  
ST_ApproximateMedialAxis — Compute the approximate medial axis of an areal geometry.  
  
ST_IsPlanar — Check if a surface is or not planar  
  
ST_Orientation — Determine surface orientation  
  
ST_ForceLHR — Force LHR orientation  
  
ST_MinkowskiSum — Performs Minkowski sum  
  
ST_3DIntersection — Perform 3D intersection  
  
ST_3DDifference — Perform 3D difference  
  
ST_3DUnion — Perform 3D union  
  
ST_3DArea — Computes area of 3D surface geometries. Will return 0 for solids.  
  
ST_Tesselate — Perform surface Tesselation of a polygon or polyhedralsurface and returns as a TIN or collection of TINS  
  
ST_Volume — Computes the volume of a 3D solid. If applied to surface (even closed) geometries will return 0.  
  
ST_MakeSolid — Cast the geometry into a solid. No check is performed. To obtain a valid solid, the input geometry must be a closed Polyhedral Surface or a closed TIN.  
  
ST_IsSolid — Test if the geometry is a solid. No validity check is performed.  

ST_Extrude is a handy function for doing things like this:

4
Fig: Simulated extruded building footprints from City Engine

ST_StraightSkeleton does in one step the first phase of what has been going on about for a couple of years — Voronoi diagrams (and bypasses Voronoi altogether):

5
Fig: Approximation of straight skeleton/skeletonization of stream polygon

In advance of an SFCGAL install guide for PostGIS, a good source for info on install can be gleaned from the PostGIS Developers listserve.

0 0 0
Share on

digoal

282 posts | 24 followers

You may also like

Comments