I do not quite understand the behaviour of ST_Intersection applied to 3D geomerties when using the GEOS backend. Take this example:

SELECT ST_AsText(ST_Intersection('POLYGON((1 1 1, 6 1 3, 6 4 3, 1 4 1, 1 1 1))'::geometry
, 'LINESTRING(-1 0.5 2, 0 1 1, 2 2 2, 3 3 3, 6 5 2)'::geometry));

This gives me the result:

LINESTRING(1 1.5 1.25,2 2 2,3 3 3,4.5 4 2.45)

Visualizing this in 3D gives me: 3d plot st_intersection 3d linestring with 3d polygon I have read in another post that for two linestrings crossing it takes the average Z-Value of the linestrings on the intersection point.

But it seems in this case the behaviour is a bit different. Only the edge nodes of the intersection line seem to show the average-Z value behaviour.

  • What do you mean by the edge nodes of the intersection line? Do you mean for the points where the line intersects the polygon? – John Powell Jun 10 at 9:56
  • I mean the start and end point of the green intersection line. Only these seem to show the average-Z value behaviour. – SPA Jun 11 at 7:38
  • My understanding is that you only get the averaging behaviour on noded intersections, ie, where the linestring and polygon's lines intersect, not for points in the interior of the polygon- – John Powell Jun 11 at 9:16
  • Yes it seems so. For me it just seems like a strange behaviour. Why not apply the Z averaging to every point of the intersection line? – SPA Jun 11 at 13:58
  • How do you define a point on a vector? Vector to raster is a complex problem on its own, so assigning only at line intersections seems very sensible. If you want the "right" answer, why don't you use the sfcgal versions. Or do the interpolation yourself, it is easy enough, using ST_Line_Interpolate_Point. – John Powell Jun 11 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.