2

This is an example where a MultiPolygon type geometry is divided with the ST_Split function, the result is two polygon type geometries that join with ST_Union to build the original geometry.

SELECT ST_AsText(ST_Multi(ST_Union(array_agg(t2.splitgeoms)))) as checkgeom FROM (SELECT (ST_Dump(ST_Split(t.origingeom, t.blade))).geom as splitgeoms FROM (SELECT ST_GeomFromText('MULTIPOLYGON(((422724.4094 2114051.9141,422711.9283 2112127.0763,421360.0089 2111149.7395,421156.2348 2110653.5001,421068.9332 2110401.6095,421399.133 2109806.3043,422216.3184 2109103.8077,422461.6364 2108607.605,418963.3179 2109710.2973,419056.2332 2110446.3435,419102.3735 2110751.7852,419112.8234 2110952.7946,418467.9193 2111330.2952,418013.3755 2111671.7966,417903.7447 2112280.1212,417894.2011 2112993.5989,417710.6037 2113424.1606,419402.8895 2114964.4682,419497.7536 2114911.159,421835.4837 2114297.3669,422724.4094 2114051.9141)))',32614) AS origingeom,
                          ST_GeomFromText('SRID=32614;LineString (416126.35021602374035865 2112131.29296381864696741, 419745.03656649653567001 2112394.47015294386073947, 421784.65978221758268774 2113052.41312575712800026, 423042.97571772278752178 2112604.18947552843019366)',32614) AS blade) as t) as t2

Subsequently, the geometry obtained with the original geometry is checked with ST_Equals. In theory the geometries should be equal but they are not and with ST_Difference we see where they are not equal.

SELECT ST_Equals(t.checkgeom, t.origingeom), ST_Difference(t.checkgeom, t.origingeom) FROM (select ST_GeomFromText('MULTIPOLYGON(((422715.77775723 2112720.74038302,422711.9283 2112127.0763,421360.0089 2111149.7395,421156.2348 2110653.5001,421068.9332 2110401.6095,421399.133 2109806.3043,422216.3184 2109103.8077,422461.6364 2108607.605,418963.3179 2109710.2973,419056.2332 2110446.3435,419102.3735 2110751.7852,419112.8234 2110952.7946,418467.9193 2111330.2952,418013.3755 2111671.7966,417907.224718196 2112260.81110943,417903.7447 2112280.1212,417894.2011 2112993.5989,417710.6037 2113424.1606,419402.8895 2114964.4682,419497.7536 2114911.159,421835.4837 2114297.3669,422724.4094 2114051.9141,422715.77775723 2112720.74038302)))',32614) AS checkgeom, ST_GeomFromText('MULTIPOLYGON(((422724.4094 2114051.9141,422711.9283 2112127.0763,421360.0089 2111149.7395,421156.2348 2110653.5001,421068.9332 2110401.6095,421399.133 2109806.3043,422216.3184 2109103.8077,422461.6364 2108607.605,418963.3179 2109710.2973,419056.2332 2110446.3435,419102.3735 2110751.7852,419112.8234 2110952.7946,418467.9193 2111330.2952,418013.3755 2111671.7966,417903.7447 2112280.1212,417894.2011 2112993.5989,417710.6037 2113424.1606,419402.8895 2114964.4682,419497.7536 2114911.159,421835.4837 2114297.3669,422724.4094 2114051.9141)))',32614) AS origingeom) AS t

How do I verify that the geometry division is equal to the original geometry?

1

In general overlay operations such as ST_Split are liable to change vertices slightly, due to numeric rounding. So generally it is NOT the case that

A = ST_Union(ST_Split(A, B))

You could try comparing the areas of the original and the split geometries - they should be close (but will not be equal, due to the above behaviour).

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.