4

ST_Tesselate returns TIN geometry. But then I need to use other software to process geometry data and it only accept (multi-)linestrings and (multi-)polygons.

Is there way to convert TIN triangles to multipolygon?

TIN is 2-dimentional, no Z coordinate.

2
  • Without knowing your source data, could you perhaps use postgis.net/docs/ST_DelaunayTriangles.html instead?
    – user30184
    Commented Sep 7, 2016 at 11:33
  • No, ST_DelaunayTriangles collects all points and creates convex surface and trianglates it as shown on illustration on that page you provided link to. I don't need creating convex polygon, I just need trianglate existing multipolygons. Commented Sep 7, 2016 at 12:43

1 Answer 1

4

You can use ST_Dump to extract individual TRIANGLE elements from the TIN. Then, you can convert an individual TRIANGLE to a POLYGON using ST_ExteriorRing and ST_MakePolygon. If you then need to combine these polygons into a single MULTIPOLYGON, you could use ST_Collect. Putting that all together would look like this:

WITH test_geom AS (SELECT 'POLYGON (( 10 190, 10 70, 80 70, 80 130, 50 160, 120 160, 120 190, 10 190 ))'::geometry AS geom)

SELECT ST_Collect(geom) AS geom 
FROM (
  SELECT ST_MakePolygon(ST_ExteriorRing((ST_Dump(ST_Tesselate(geom))).geom)) AS geom 
  FROM test_geom) sq;
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.