31 Mart 2022 Perşembe

PostGIS ST_MakeValid

Giriş
Açıklaması şöyle. Yani polygon gibi bir şekilde hata varsa düzeltmek için kullanılır
Ring self-intersection errors are often caused by "inverted polygons" - i.e. polygons with holes represented by the shell self-touching, rather than by a separate hole ring (which is the only representation the OGC model allows).

If this is the cause of the invalidities, then it should be safe to use ST_MakeValid.

Other kinds of invalidity are potentially safe as well. It might help if you can post some data examples. Or try it out. You could use ST_Area on the original and fixed geometries to see if the geometry has changed too much.
Örnek
Şöyle yaparız
with src(geog) as (values ('polygon((0 40,50 40, 50 20, 0 20, 0 40),(25 25, 25 51, 26 25, 25 25))'::geography))
select 
    st_isValid(st_transform(geog::geometry,102034)) isvalid_gnomonic,
    st_transform(
      st_makeValid(
       st_transform(geog::geometry,102034),
      'method=structure'),
     4326)::geography  as valid_gnomonic_structure
FROM src;