0

I have plenty of very tiny adjacent TIN chunks in a PostgreSQL 15 / PostGIS 3.4 database.

I would like to merge them all into a single one.

I've tried both ST_Collect and ST_3DUnion but they both gives a GeometryCollection whereas I want to have a single TIN.

Here's a dummy snippet of code:

SELECT ST_AsText(ST_3DUnion(
    ST_GeomFromText('TIN (
        ((2.4 1.1 4.6,2.5 1.2 4.2,2.4 1.1 4.2,2.4 1.1 4.6)),
        ((2.4 1.1 4.6,2.5 1.2 4.6,2.5 1.2 4.2,2.4 1.1 4.6)))'
    ),
    ST_GeomFromText('TIN (
        ((2.4 1.1 4.6,2.45 1.02 4.6,2.45 1.02 4.2,2.4 1.1 4.6)),
        ((2.4 1.1 4.2,2.4 1.1 4.6,2.45 1.02 4.2,2.4 1.1 4.2)))'
    )        
))
--------
GEOMETRYCOLLECTION Z (
    TIN Z (((2.4 1.1 4.6,2.5 1.2 4.2,2.4 1.1 4.2,2.4 1.1 4.6)),
           ((2.4 1.1 4.6,2.5 1.2 4.6,2.5 1.2 4.2,2.4 1.1 4.6))),
    TIN Z (((2.4 1.1 4.6,2.45 1.02 4.6,2.45 1.02 4.2,2.4 1.1 4.6)),
           ((2.4 1.1 4.2,2.4 1.1 4.6,2.45 1.02 4.2,2.4 1.1 4.2)))
)
(1 row)

What I would like as an output is:

TIN (
((2.4 1.1 4.6,2.5 1.2 4.2,2.4 1.1 4.2,2.4 1.1 4.6)),
((2.4 1.1 4.6,2.5 1.2 4.6,2.5 1.2 4.2,2.4 1.1 4.6)),
((2.4 1.1 4.6,2.45 1.02 4.6,2.45 1.02 4.2,2.4 1.1 4.6)),
((2.4 1.1 4.2,2.4 1.1 4.6,2.45 1.02 4.2,2.4 1.1 4.2))
)

How can I achieve that?

1 Answer 1

0

TIN support is unfortunately pretty limited in PostGIS. You probably have to merge the TIN values together in the textual domain, by stripping the leading TIN( and trailing ), concatenating with a comma separator, and adding the leading TIN( and trailing ) again.

2
  • This is exactly what I'm currently doing as a workaround, but I don't like such "tinkering" because it's kind of an antipattern for me. Dec 19, 2022 at 19:00
  • In the absence of this functionality in PostGIS, that's probably the best that can be done. It should be a fairly robust solution (i.e. unlikely to break with new releases of PostGIS).
    – dr_jts
    Dec 19, 2022 at 22:09

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.