postgis_sfcgal

PostGIS SFCGAL functions

Overview

PackageVersionCategoryLicenseLanguage
postgis3.6.2GISGPL-2.0C
IDExtensionBinLibLoadCreateTrustRelocSchema
1500postgisNoYesNoYesNoNo-
1501postgis_topologyNoYesNoYesNoNotopology
1502postgis_rasterNoYesNoYesNoNo-
1503postgis_sfcgalNoYesNoYesNoYes-
1504postgis_tiger_geocoderNoYesNoYesYesNotiger
1505address_standardizerNoYesNoYesNoYes-
1506address_standardizer_data_usNoYesNoYesNoYes-
Relatedpostgis pgrouting pointcloud pointcloud_postgis h3 h3_postgis q3c ogr_fdw geoip

Version

TypeRepoVersionPG VerPackageDeps
EXTPGDG3.6.21817161514postgispostgis
RPMPGDG3.6.21817161514postgis36_$v-
DEBPGDG3.6.21817161514postgresql-$v-postgis-3-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64PGDG 3.6.1PGDG 3.6.1PGDG 3.6.1PGDG 3.6.1PGDG 3.6.1
el8.aarch64PGDG 3.6.1PGDG 3.6.1PGDG 3.6.1PGDG 3.6.1PGDG 3.6.1
el9.x86_64PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2
el9.aarch64PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2
el10.x86_64PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2
el10.aarch64PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2
d12.x86_64PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2
d12.aarch64PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2
d13.x86_64PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2
d13.aarch64PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2
u22.x86_64PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2
u22.aarch64PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2
u24.x86_64PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2
u24.aarch64PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2PGDG 3.6.2

Install

You can install postgis directly. First, make sure the PGDG repository is added and enabled:

pig repo add pgdg -u          # Add PGDG repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install postgis;          # Install for current active PG version
pig ext install -y postgis -v 18  # PG 18
pig ext install -y postgis -v 17  # PG 17
pig ext install -y postgis -v 16  # PG 16
pig ext install -y postgis -v 15  # PG 15
pig ext install -y postgis -v 14  # PG 14
dnf install -y postgis36_18       # PG 18
dnf install -y postgis36_17       # PG 17
dnf install -y postgis36_16       # PG 16
dnf install -y postgis36_15       # PG 15
dnf install -y postgis36_14       # PG 14
apt install -y postgresql-18-postgis-3   # PG 18
apt install -y postgresql-17-postgis-3   # PG 17
apt install -y postgresql-16-postgis-3   # PG 16
apt install -y postgresql-15-postgis-3   # PG 15
apt install -y postgresql-14-postgis-3   # PG 14

Create Extension:

CREATE EXTENSION postgis_sfcgal CASCADE;  -- requires: postgis

Usage

PostGIS SFCGAL: 3D geometry and advanced operations powered by SFCGAL

PostGIS SFCGAL provides advanced 2D and 3D spatial operations by wrapping the SFCGAL library. It adds support for 3D geometry operations, volume calculations, extrusion, tesselation, and other functions not available in the core PostGIS GEOS backend.

Setup

CREATE EXTENSION postgis_sfcgal;

3D Operations

3D Intersection and Difference

-- 3D intersection of two solids
SELECT ST_3DIntersection(
    ST_GeomFromText('POLYHEDRALSURFACE Z(((0 0 0,1 0 0,1 1 0,0 1 0,0 0 0)),((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)),((0 0 0,0 1 0,0 1 1,0 0 1,0 0 0)),((1 0 0,1 1 0,1 1 1,1 0 1,1 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),((0 1 0,1 1 0,1 1 1,0 1 1,0 1 0)))'),
    ST_GeomFromText('POLYHEDRALSURFACE Z(((0.5 0.5 0.5,1.5 0.5 0.5,1.5 1.5 0.5,0.5 1.5 0.5,0.5 0.5 0.5)),((0.5 0.5 1.5,1.5 0.5 1.5,1.5 1.5 1.5,0.5 1.5 1.5,0.5 0.5 1.5)),((0.5 0.5 0.5,0.5 1.5 0.5,0.5 1.5 1.5,0.5 0.5 1.5,0.5 0.5 0.5)),((1.5 0.5 0.5,1.5 1.5 0.5,1.5 1.5 1.5,1.5 0.5 1.5,1.5 0.5 0.5)),((0.5 0.5 0.5,1.5 0.5 0.5,1.5 0.5 1.5,0.5 0.5 1.5,0.5 0.5 0.5)),((0.5 1.5 0.5,1.5 1.5 0.5,1.5 1.5 1.5,0.5 1.5 1.5,0.5 1.5 0.5)))')
);

-- 3D difference
SELECT ST_3DDifference(solid_a, solid_b) FROM solids;

-- 3D union
SELECT ST_3DUnion(solid_a, solid_b) FROM solids;

3D Measurements

-- 3D area of a surface
SELECT ST_3DArea(geom) FROM surfaces;

-- Volume of a solid
SELECT ST_Volume(geom) FROM solids;

Extrusion

-- Extrude a 2D polygon into a 3D solid
SELECT ST_Extrude(
    ST_GeomFromText('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'),
    0, 0, 10  -- dx, dy, dz
);

Tesselation and Triangulation

-- Tesselate a polygon into triangles
SELECT ST_Tesselate(
    ST_GeomFromText('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))')
);

-- Constrained Delaunay triangulation
SELECT ST_ConstrainedDelaunayTriangles(
    ST_GeomFromText('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))')
);

Other Functions

-- Straight skeleton of a polygon
SELECT ST_StraightSkeleton(
    ST_GeomFromText('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))')
);

-- Approximate medial axis
SELECT ST_ApproximateMedialAxis(
    ST_GeomFromText('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))')
);

-- Minkowski sum
SELECT ST_MinkowskiSum(
    ST_GeomFromText('LINESTRING(0 0, 4 0)'),
    ST_GeomFromText('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))')
);

-- Check planarity of a surface
SELECT ST_IsPlanar(geom) FROM surfaces;

Last Modified 2026-03-12: add pg extension catalog (95749bf)