43
Automatically repairing polygons and planar partitions with prepair and pprepair Ken Arroyo Ohori Hugo Ledoux Martijn Meijers OSGIS 2012 September 5, 2012 1 / 22

Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Automatically repairing polygons and planarpartitions with prepair and pprepair

Ken Arroyo Ohori Hugo Ledoux Martijn Meijers

OSGIS 2012September 5, 2012

1 / 22

Page 2: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Planar partition = no gaps, no overlaps

2 / 22

Page 3: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Real data = problems

3 / 22

Page 4: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Real data = problems

3 / 22

Page 5: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

What about polygons?

OGC Simple Features +ISO19107:

1 no self-intersection

2 closed boundaries

3 rings can touch but notoverlap

4 no duplicate points

5 no dangling edges

6 connected interior

p2

p4 p5 p6

p7 p8 p9

p3

p12p11p10

p1

exteriorboundary

interiorboundary

4 / 22

Page 6: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Real data = problems

5 / 22

Page 7: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Real data = problems

5 / 22

Page 8: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Real data = problems

5 / 22

Page 9: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Standards/definitions tell us what is valid, but...what to do with invalid data?

Planar partitions: snapping / topology rules /manual work

Polygons: “buffer-by-0” / PostGIS 2.0’sST MakeValid() / “visual repair”

6 / 22

Page 10: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Snapping

Tolerance (threshold) isused for snapping vertices

Tolerance based on scale ofdatasets

Works fine for simpleproblems

7 / 22

Page 11: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Snapping

Tolerance (threshold) isused for snapping vertices

Tolerance based on scale ofdatasets

Works fine for simpleproblems

7 / 22

Page 12: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Snapping

Tolerance (threshold) isused for snapping vertices

Tolerance based on scale ofdatasets

Works fine for simpleproblems

7 / 22

Page 13: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Snapping

Spikes and punctures can create invalid polygons

8 / 22

Page 14: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Snapping

Spikes and punctures can create invalid polygons

8 / 22

Page 15: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Snapping

Splitting of polygons into several polygons

8 / 22

Page 16: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Snapping

Splitting of polygons into several polygons

8 / 22

Page 17: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Snapping

High resolution data

Low resolution data

Topologically invalid result

8 / 22

Page 18: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Topology rules

9 / 22

Page 19: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Manual work

10 / 22

Page 20: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

“Buffer-by-0”

11 / 22

Page 21: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

“Buffer-by-0”

11 / 22

Page 22: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

“Buffer-by-0”

planar graph is constructed

11 / 22

Page 23: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

“Buffer-by-0”

Result

11 / 22

Page 24: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

PostGIS 2.0’s ST MakeValid()

high-level automatic repair function

diff functions called depending on geometric and topologicalconfigurations of rings

based on construction of planar graph (GEOS is used)

not documented (“read the code”) = predicting behaviour isdifficult

very slow for big polygons

12 / 22

Page 25: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

“Visual repair”

GRASS ArcGIS

13 / 22

Page 26: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Our solution = constrained triangulation (CT)

1 Construct CT of inputpolygons

2 Flag each triangle with itspolygon / interior & exterior

3 Make each triangle haveexactly one tag

4 Reconstruct polygons

over

lapp

ing

region

"red"

"blue"

14 / 22

Page 27: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Our solution = constrained triangulation (CT)

1 Construct CT of inputpolygons

2 Flag each triangle with itspolygon / interior & exterior

3 Make each triangle haveexactly one tag

4 Reconstruct polygons

"red"

"blue"

14 / 22

Page 28: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Our solution = constrained triangulation (CT)

1 Construct CT of inputpolygons

2 Flag each triangle with itspolygon / interior & exterior

3 Make each triangle haveexactly one tag

4 Reconstruct polygons

A

C

D

B

"red"

"blue"

14 / 22

Page 29: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Our solution = constrained triangulation (CT)

1 Construct CT of inputpolygons

2 Flag each triangle with itspolygon / interior & exterior

3 Make each triangle haveexactly one tag

4 Reconstruct polygons

Triangle Repair

ABCD

"red""red""red""red"

14 / 22

Page 30: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Our solution = constrained triangulation (CT)

1 Construct CT of inputpolygons

2 Flag each triangle with itspolygon / interior & exterior

3 Make each triangle haveexactly one tag

4 Reconstruct polygons

"red"

"blue"

14 / 22

Page 31: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Our solution = constrained triangulation (CT)

1 Construct CT of inputpolygons

2 Flag each triangle with itspolygon / interior & exterior

3 Make each triangle haveexactly one tag

4 Reconstruct polygons

"red"

"blue"

14 / 22

Page 32: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Local control: 6 different operators

Repair operation Type Criteria

Triangle by number of Focal The label present in the largest number ofneighbours adjacent faces, overlaps included.Triangle by absolute majority Focal Label present in two or more valid

adjacent facesTriangle by longest boundary Focal Label present along the longest portion of

the boundary of the adjacent facesRegions by longest boundary Focal of Label present along the longest portion of

zonal the boundary of the adjacent facesRegions by random neighbour Focal of Random label from the adjacent faces

zonalTriangle by priority list Varies Label that has the highest priority according to

a predefined priority list

15 / 22

Page 33: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Local control: one concrete example

16 / 22

Page 34: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Local control: one concrete example

16 / 22

Page 35: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Local control: one concrete example

16 / 22

Page 36: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Local control: one concrete example

16 / 22

Page 37: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Local control: one concrete example

16 / 22

Page 38: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Experiments with big polygons: CORINE2006

32 473 points346 rings

2 412 points10 rings

102 272 points299 rings

points rings prepair ST MakeValid()

EU-47552 2 412 10 0.5s 0.8sEU-47997 32 473 346 11.4s 314.0sEU-180927 102 272 299 52.2s 740.2s

17 / 22

Page 39: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Experiments with large real-world datasets

(a) E41N27 (b) 4tiles

(c) 16tiles (d) Mexico18 / 22

Page 40: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Experiments with large real-world datasets

# pts avg # pts# polygons # pts largest polygon per polygon

E41N27 14 969 496 303 26 740 344tiles 4 984 365 702 16 961 7516tiles 63 868 6 622 133 95 112 104Mexico 26 866 4 181 354 117 736 156

19 / 22

Page 41: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

Comparison with other GIS packages

pprepair ArcGIS FME GRASS

memory time memory time memory time memory time

E41N27 145 MB 19s 145 MB 1m3s 158 MB 31s 59 MB 3m09s4tiles 116 MB 17s 113 MB 37s 105 MB 31s 49 MB 53s16tiles 1.45 GB 4m47s crashes – 636 MB 15m48s crashes –Mexico 1.01 GB 3m31s 216 MB >1d 264 MB 2m45s 408 MB 11m38s

20 / 22

Page 42: Automatically repairing polygons and planar partitions ... · very slow for big polygons 12/22 \Visual repair" GRASS ArcGIS 13/22. Our solution = constrained triangulation (CT) 1

The code is robust and freely available

http://tudelft-gist.github.com/pprepair

Uses OGR and CGALBSD license → soon GPLv3

21 / 22