Name

CG_ApproximateMedialAxis — Compute the approximate medial axis of an areal geometry.

Synopsis

geometry CG_ApproximateMedialAxis(geometry geom);

geometry CG_ApproximateMedialAxis(geometry geom, boolean projected);

Description

Return an approximate medial axis for the areal input based on its straight skeleton. Uses an SFCGAL specific API when built against a capable version (1.2.0+). Otherwise the function is just a wrapper around CG_StraightSkeleton (slower case).

When projected is true, free endpoints of the medial axis are extended to reach the polygon boundary (projected medial axis). Requires SFCGAL 2.3.0+. When built against an older SFCGAL version, a notice is emitted and the non-projected result is returned instead.

Availability: 3.5.0

Availability: 3.7.0 - projected parameter. Requires SFCGAL >= 2.3.0 for projected result; falls back to non-projected with a notice on older versions.

[Note]

This function ignores the Z dimension. It always gives a 2D result even when used on a 3D geometry.

This method needs SFCGAL backend.

This function supports Polyhedral surfaces.

This function supports Triangles and Triangulated Irregular Network Surfaces (TIN).

Examples

SELECT CG_ApproximateMedialAxis(ST_GeomFromText('POLYGON (( 190 190, 10 190, 10 10, 190 10, 190 20, 160 30, 60 30, 60 130, 190 140, 190 190 ))'));

A polygon and its approximate medial axis

-- Projected medial axis: free endpoints extended to polygon boundary
SELECT CG_ApproximateMedialAxis('POLYGON((0 0,2 0,2 1,0 1,0 0))', true);
-- Result: MULTILINESTRING((0 0.5,2 0.5))