Name

ST_Snap — Snaps the vertices and segments of a Geometry to another Geometry's vertices. A snapping distance tolerance is used to control where snapping is performed.

Synopsis

geometry ST_Snap(bytea GeomA, bytea GeomB, double Tolerance);

Alias

Snap

Description

Snaps the vertices and segments of a Geometry to another Geometry's vertices. Improves robustness for overlay operations, by eliminating nearly parallel edges (which cause problems during noding and intersection calculation).

Coordinate Dimensions
2D3DM
Spatial Standards Support
OGC SFS for SQL. 1.1 (1999)OGC SFS for SQL. 1.1.0 (2005)OGC SFS for SQL. 1.2.0 (2006)SQL-MM Part 3
----

Examples

--Ex. 1
SELECT ST_AsText(ST_SNAP(A,B,2)) As C FROM (
SELECT ST_GeomFromText('POLYGON ((1 1, 1 4, 4.5 6.8, 4.6 0.3, 1 1))') As A, 
ST_GeomFromText('POLYGON ((6 2, 6 3, 8 3, 8 2, 6 2))') As B) as foo; 

--Result
                           C
-------------------------------------------------------
 POLYGON ((1 1, 1 4, 4.5 6.8, 6 3, 6 2, 4.6 0.3, 1 1))

--Ex. 2
SELECT ST_AsText(ST_SNAP(A,B,2)) As C FROM (
SELECT ST_GeomFromText('POLYGON ((1 1, 1 4, 4 4, 4 1, 1 1))') As A, 
ST_GeomFromText('POLYGON ((5 0.7, 7 4.8, 8 3, 8 2, 5 0.7))') As B) as foo; 

--Result:
C  
POLYGON ((1 1, 1 4, 4 4, 5 0.7, 1 1))
Ex. 1 A,B
ST_Snap(A,B,2) as C
Ex. 2 A,B
ST_Snap(A,B,2) as C

Related functions

ST_SnapToGrid