I recently received a PostGIS instance and am trying to figure out how much of my current processing workflow (in proprietary tools) can be ported over to PostGIS.
One of the most frequent tasks I encounter is validating/repairing geometry.
Here's what I've done and here's where I'm stuck:
I load some data (multipolygon) to postGIS. Then I use the following statement to identify and copy invalid geometries to a different table:
create table broken_polygons as
select * from polygons
where not st_isvalid(geom);
Then, I get rid of the offending records:
delete from polygons
where not st_isvalid(geom);
This gives me a chance to take a closer look at the bad geometry; sometimes there are only one or two, sometimes there are hundreds. But when I try to do this:
select *, st_makevalid(geom) as fixed_polygons
from "broken_polygons"
It gives me a result, but when I load up fixed_polygons
in QGIS and check the geometry validity (GEOS), all of them error out: nothing has been modified.
In this particular case, all of the errors are self-intersections.
I am using PostGIS 2.3.2 on postgres 9.6.2
I am not a DBA, just someone trying to get things done with the tools in front of me; so I seek examples of precise syntax to get ST_MakeValid to work.
No comments:
Post a Comment