ST_SNAP behaviour with 3D Geometries

Alexandre Neto senhor.neto at gmail.com
Mon Apr 13 10:15:21 PDT 2026


Hi all,

I am having trouble understanding the behaviour of St_Snap when used with
3D Geometries.

I was aware that st_snap did not properly support 3D geometries, but I
would not expect that it actually changes the Z coordinates.

I would expect that the Z coordinates would be kept untouched, but that's
not what happens.

WITH input AS (SELECT 'POINT Z (1.001 1.001 50)'::geometry AS geom),

reference AS (SELECT 'POINT Z (1.0 1.0 999)'::geometry AS geom)

SELECT

ST_AsEWKT(ST_Snap(i.geom, r.geom, 0.01)) AS snapped,

ST_Z(ST_Snap(i.geom, r.geom, 0.01)) AS z_after_snap,

ST_Z(i.geom) AS z_original

FROM input i, reference r;




*snapped
|z_after_snap|z_original|--------------+------------+----------+POINT(1 1
999)|       999.0|      50.0|*

In fact, not only the Z coordinate gets changed as it completely ignores
the tolerance.

I then tried to use ST_Force2D around the reference geometry, but the
result is kind of expected, a 2D geometry with no Z coordinate.

I wonder if these are the expected behaviour of ST_snap and there is more a
convenient way to snap 3D geometries in 2D while ignoring the Z component
without needing to recover all vertices Zs from the original geometry.

Thanks,

Alexandre Neto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20260413/1abd6371/attachment.htm>


More information about the postgis-users mailing list