# [postgis-users] st_intersection of 3D objects

Regina Obe lr at pcorp.us
Thu Apr 27 13:53:37 PDT 2023

```I think for this case, this behavior is expected.

When you say – it used to return ‘POINT Z(0 0 2.5)’  which version of GEOS and PostGIS were you running?

If you passed in a 2 dimensional point and a 3-dimentional line, then you would get interpolation on the z as it would treat the 2-D point as an infinite vertical line.

Take for example:

SELECT ST_AsText(ST_intersection('POINT(0 0)'::geometry, 'LINESTRINGZ ( 0 0 5, 0 0 3, 0 2 3)'::geometry));

Yields:  POINT Z (0 0 4)

But in the case of a point 3d and a point 3d line.  The routine I think it goes thru is

1) 2D intersects – yes they intersect

2) If one is a 3d point, then return the point

If you gave it two 3D linestrings or a polygon, you should see the interpolation behavior you are expecting.

From: postgis-users [mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of Alexandre Neto
Sent: Thursday, April 27, 2023 11:28 AM
To: PostGIS Users Discussion <postgis-users at lists.osgeo.org>
Subject: [postgis-users] st_intersection of 3D objects

Hi,

PostGIS documentation for the st_intersection <https://postgis.net/docs/ST_Intersection.html>  states the following

If working with 3D geometries, you may want to use SFGCAL based ST_3DIntersection <https://postgis.net/docs/ST_3DIntersection.html>  which does a proper 3D intersection for 3D geometries. Although this function works with Z-coordinate, it does an averaging of Z-Coordinate.

I have used that averaging in the past, but it seems that I can no longer use it in PostgreSQL 14 and PostGIS 3.3.2 (POSTGIS="3.3.2 4975da8" [EXTENSION] PGSQL="140" GEOS="3.10.2-CAPI-1.16.0" PROJ="8.2.1" LIBXML="2.9.13" LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)")

SELECT ST_AsText(ST_Intersection('POINTZ(0 0 0)'::geometry, 'LINESTRINGZ ( 0 0 5, 0 2 5)'::geometry));

Used to return:

'POINT Z (0 0 2.5)'

but now it returns

'POINT Z (0 0 0)'

Is this expected or a bug.

Greetings,

Alexandre Neto

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20230427/870a9bbb/attachment.htm>
```