[postgis-users] ST_MakeValid

Stephen V. Mather svm at clevelandmetroparks.com
Mon Apr 16 12:02:13 PDT 2012


Forgot to reply all... 

> The ST_MakeValid tries its best to retain all input vertices.

AFAIK, Horst's function does as well.

> Also, ST_MakeValid internally checks for input validity and avoids 
> running anything if the input is valid. Such check has a cost too.

Horst's function naturally leverages the old "isValid".

I'm going to try on one of the datasets that Horst's function fails on, as I
suspect the new native function is less likely to fail.  I'll take stability
over speed (most of the time, anyway...).

FYI, an excerpt from the code from Horst's function 

---------------------

http://www.sogis1.so.ch/sogis/dl/postgis/cleanGeometry.sql


Does the following for the polygon case:

IF (GeometryType(inGeom) = 'POLYGON' OR GeometryType(inGeom) =
'MULTIPOLYGON') THEN

-- Only process if geometry is not valid,
-- otherwise put out without change
    if not isValid(inGeom) THEN
    
-- create nodes at all self-intersecting lines by union the polygon
boundaries
-- with the startingpoint of the boundary.  
      tmpLinestring :=
st_union(st_multi(st_boundary(inGeom)),st_pointn(boundary(inGeom),1));
      outGeom = buildarea(tmpLinestring);      
      IF (GeometryType(inGeom) = 'MULTIPOLYGON') THEN      
        RETURN st_multi(outGeom);
      ELSE
        RETURN outGeom;
      END IF;
    else    
      RETURN inGeom;
    END IF;
...


Best,
Steve

Stephen Mather
Geographic Information Systems (GIS) Manager
(216) 635-3243
svm at clevelandmetroparks.com
clevelandmetroparks.com




-----Original Message-----
From: Sandro Santilli [mailto:sandro.santilli at gmail.com] On Behalf Of Sandro
Santilli
Sent: Monday, April 16, 2012 12:41 PM
To: svm at clevelandmetroparks.com; PostGIS Users Discussion
Subject: Re: [postgis-users] ST_MakeValid

On Mon, Apr 16, 2012 at 12:33:15PM -0400, Stephen V. Mather wrote:

> Then a quick run through cleanGeometry:
...
> Query returned successfully: 1004952 rows affected, 955444 ms execution
time.
> 
> If I run as ST_MakeValid,
...
> At 2300000 milliseconds, it is still running. .

The ST_MakeValid tries its best to retain all input vertices.

IIRC there's a difference with a multipolygon composed by two
overlapping rectangles.

Also, ST_MakeValid internally checks for input validity and avoids
running anything if the input is valid. Such check has a cost too.

--strk;

  ,------o-. 
  |   __/  |    Delivering high quality PostGIS 2.0 !
  |  / 2.0 |    http://strk.keybit.net - http://vizzuality.com
  `-o------'








More information about the postgis-users mailing list