2

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.

  • Without knowing your source data, could you perhaps use postgis.net/docs/ST_DelaunayTriangles.html instead? – user30184 Sep 7 '16 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. – Roman Shuvalov Sep 7 '16 at 12:43
3

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;

Your Answer

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

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