I have a workflow where I am creating Voronoi polygons from a series of points. However since the polygons on the exterior extend really far out I have clipped them and then joined them back to points to get the IDs back. However when I join them back based on a ST_Intersects about 1-2% of them get lost. Here is the original Voronoi polygons and then after the intersection.
Here is the code that I am using
CREATE OR REPLACE VIEW voronoi_test AS WITH voronoi_temp2 AS ( SELECT (ST_dump(ST_VoronoiPolygons(ST_Collect(the_geom)))).geom as the_geom FROM ways_vertices_pgr) SELECT id, voronoi_temp2.the_geom FROM voronoi_temp2 JOIN ways_vertices_pgr ON ST_Intersects(ways_vertices_pgr.the_geom, voronoi_temp2.the_geom);
Upon further inspection of the geometries those that drop out have duplicated points. So something like [(0, 0), (1, 0.5), (1, 0.5), (0, 1), (0, 0)]. So they are self-intersecting and invalid. I have tried MakeValid and RemoveRepeatedPoints but both end up dropping the invalid polygons.
This only occurs when the data is in a geographic coordinate system and not when in a projected coordinate system.