I have a problem that ST_VoronoiPolygons
started to give me GEOSVoronoiDiagram: TopologyException: Input geom 1 is invalid: Self-intersection
The function that I use it for have worked for a long time for me.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityI have a problem that ST_VoronoiPolygons
started to give me GEOSVoronoiDiagram: TopologyException: Input geom 1 is invalid: Self-intersection
The function that I use it for have worked for a long time for me.
The problem was connected to that the data I had was in a perfect grid. I don't know why but ST_VoronoiPolygons
couldn't handle it.
So what I did was that I altered the points slightly (I use Python to populate the data so I added import random
and + random.gauss(0.00000001, 0.00000001)
to the x and y coordinate)
ST_SnapToGrid
, hence when I used a size "small enough" I got the same problem.
Jun 21, 2018 at 10:59
Maybe there was a self-intersection... Have you tried ST_isValid and ST_isValidDetail functions? The second one could tell you where exactly this intersection is. The simplest way to deal with them is to use ST_Buffer function with radius = 0 - that's because ST_Buffer is creating brand new geometry based on origin and this geometry is always valid. With radius 0 you'll get exactly the same geometry but without self-intersections.
ST_MakeValid(geom)
a better option to ST_Buffer(geom, 0)
? Seems more intentional.
Oct 18, 2021 at 22:33
ST_VoronoiPolygons
essentially interprets its inputs as aMultiPoint
, no matter what the actual geometry type is, so the concept of validity doesn't really apply.