[postgis-users] st_intersection of 3D objects
Alexandre Neto
senhor.neto at gmail.com
Fri Apr 28 07:26:26 PDT 2023
Ok, so, It seems that it works differently depending of the input geometries. With two linestrings it works.
SELECT st_intersection('LINESTRINGZ(0 0 5, 10 10 5)'::geometry, 'LINESTRINGZ(0 10 0, 10 0 0)'::geometry); POINT Z(5 5 2.5)
The 2 lines intersect in 2D, but not in 3D. Hence, the resulting point has the correct X and Y and the Z is an average of both lines on that point. And probably that was what I remember:
So I wonder why the different results if I use points. Even in a easier case:
SELECT st_intersection('POINTZ(0 0 0)'::geometry, 'POINTZ(0 0 10)'::geometry); POINT Z(0 0 0)
SELECT st_intersection('POINTZ(0 0 10)'::geometry, 'POINTZ(0 0 0)'::geometry); POINT Z(0 0 10)
Meanwhile, it seems that, it the two linestrings intersection have share a vertice in 2D, the average is also not calculated and the first geometry Z values prevails.
SELECT st_intersection('LINESTRINGZ(0 0 5, 5 5 5, 10 10 5)'::geometry, 'LINESTRINGZ(0 10 0, 5 5 0, 10 0 0)'::geometry) POINT Z(5 5 5)
Alexandre Neto
On Fri Apr 28, 2023, 03:54 AM GMT, Mike Taves <mailto:mwtoews at gmail.com> wrote:
> On Fri, 28 Apr 2023 at 08:54, Regina Obe <lr at pcorp.us> wrote:
>> When you say – it used to return ‘POINT Z(0 0 2.5)’ which version of GEOS and PostGIS were you running?
>
> I also see this with an older version:
> POSTGIS="2.4.0 r15853" PGSQL="96" GEOS="3.5.0-CAPI-1.9.0 r4084"
> PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.11.4, released
> 2016/01/25" LIBXML="2.9.1" LIBJSON="0.11" RASTER
>
> But the expected answer really is not certain, since they don't intersect in 3D.
>
> Another answer, using linear interpolation via ST_LineInterpolatePoint:
>
> db=> SELECT ST_LineLocatePoint(A, B),
> ST_AsText(ST_LineInterpolatePoint(A, ST_LineLocatePoint(A, B)))
> db-> FROM (
> db(> SELECT 'LINESTRINGZ ( 0 0 5, 0 2 5)'::geometry A, 'POINTZ(0 0
> 0)'::geometry B
> db(> ) d;
> -[ RECORD 1 ]------+----------------
> st_linelocatepoint | 0
> st_astext | POINT Z (0 0 5)
>
> So the expected Z value is either 0 for the input point, 5 for the
> input line, or 2.5 for "mid-way".
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20230428/215749e2/attachment.htm>
More information about the postgis-users
mailing list