第一步,postgis导入shp。
第二步,CREATE TABLE temp1 as SELECT gid,市,ST_GeometryN(geom, generate_series(1, ST_NumGeometries(geom))) AS geom FROM sthx2019copy。复制表到temp1,但是将multipolygon转为了polygon。
第三步,
CREATE TABLE temp2 as select * from temp1 where ST_IsValid(geom) = false;
update temp2 set geom =ST_Buffer(geom, 0.0)
delete from temp1 where ST_IsValid(geom) = false
insert into temp1 select * from temp2
这样自相交的叠加分析报错就没有了。