3

I'm getting a lot of errors like this:

GEOSUnaryUnion: TopologyException: found non-noded intersection between LINESTRING (147.254 -42.8705, 147.254 -42.8705) and LINESTRING (147.254 -42.8705, 147.254 -42.8705) at 147.25355728849621 -42.870521684000678

I am calling ST_MakeValid(ST_Union(ST_SnapToGrid(mpoly))) on an aggregate of all rows that match my filter.

3
  • 1
    You want to call ST_MakeValid before ST_Union. If union runs into an invalid geometry, it's more likely to throw a topo exception
    – Regina Obe
    Oct 6, 2015 at 6:04
  • 1
    Turns out this isn't enough. Oct 8, 2015 at 0:01
  • yeah I ran MakeValid before Union and I still got this error
    – Theo F
    Feb 28, 2019 at 16:43

2 Answers 2

2

There is a similar question at How best to fix a non-noded intersection problem in PostGIS?. Some have had success by performing ST_MakeValid, ST_Buffer or ST_SnapToGrid to the geometry before to performing the union. I see you tried SnapToGrid. Have you tried something like:

ST_Union(ST_MakeValid(mpoly))

or

ST_Union(ST_Buffer(mpoly, 1e-5))

The presentation PostGIS: Tips for Power Users outlines some potential sources of trouble when unioning geometries.

0

Just change the order of functions, add the grid size to snap 0.0001 for degrees, collenct only polygons for query ( 3 stands for polygons):

Select
ST_Union(
  ST_CollectionExtract(
    ST_MakeValid(
      ST_SnapToGrid(geom,0.0001)
    ),3
  )
)
From
  mpoly

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.