All Products
Search
Document Center

PolarDB:ST_SnapToPolygon

Last Updated:Mar 28, 2026

Smoothly fits terrain mesh (sfmesh) vertices to a 3D polygon along the Z axis.

Syntax

sfmesh ST_SnapToPolygon(sfmesh sfmesh, geometry geom, f8 zlowd, f8 zupd, f8 buffer, i4 times);

Return value

Returns the sfmesh object with its vertices smoothly fit to the target polygon.

Parameters

ParameterTypeDescription
sfmeshsfmeshThe sfmesh model object whose vertices are fit to the polygon.
geomgeometryThe target 3D polygon.
zlowdf8The lower Z distance limit. Only vertices within the Z range defined by zlowd and zupd are fit.
zupdf8The upper Z distance limit. Only vertices within the Z range defined by zlowd and zupd are fit.
bufferf8The buffer used for smooth fitting.
timesi4The number of fitting iterations. More iterations produce a smoother result. Set a value between 5 and 20.

Usage notes

  • zlowd and zupd specify the vertices to be smoothly fit.

  • buffer sets the smooth transition range.

  • times defines the number of smooth fitting actions. A higher number of smooth fitting actions brings a better fitting result.

Example

The following example intersects a sphere with a bounding box to produce an sfmesh, then snaps its vertices to a thin polygon strip along the Y axis with times set to 10.

SELECT BOX3D(ST_SnapToPolygon(
    ST_3DIntersection(ST_3DMakeSphere(1.0, 4), 'BOX3D(-1 -1 0, 1 1 1)'::box3d),
    'POLYGON((-5 -0.1 0.5, 5 -0.1 0.5, 5 0.1 0.5, -5 0.1 0.5, -5 -0.1 0.5))', 0.5, 0.5, 0.5, 10));

Result:

BOX3D(-1 -1 0,1 1 0.782785594463348)