I've been looking for some function that will consider geometries from a table.

The selection would look something like this:

SELECT geom FROM mytable WHERE geoid IN (1, 10, 15, 30, 2)

How can I tell if the geometries are "contiguous" (sharing at least one point or boundary with no gaps, i.e. geometries are strung together with no breaks).

For more clarity: Assume we use the "^" as a triangle and the SELECT statement above gives this result of three geometries touching and two touching geometries by themselves: ^^^ ^^ The goal is to determine that the above condition is not contiguous, but the following would be: ^^^^^

  • Probably this is hard to do with SQL Server, but if you convert the polygon coverage into a graph and that does not have isolated islands then all boundaries are connected. – user30184 May 11 '16 at 17:55

If the area of the ST_Union equals the sum of the areas of each polygon. I think you can conclude there are no overlaps.

As I recall if you union two triangles whose corners touch, the result has two rings.

If you buffer the union by some small (epsilon) amount and the resulting geometry/geography has only one exterior ring, I think you could conclude they are contiguous.

| improve this answer | |
  • Thank you! Setting a buffer on all the shapes and use ST_Union, then count the shapes -- if the count is greater than 1, then the shapes (in combination) are not contiguous. – Mike McWilliams May 20 '16 at 14:51

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.