Giter VIP home page Giter VIP logo

prepair's Introduction

What is prepair?

prepair -- pronounce 'pee-repair' as in 'polygon repair' -- permits us to easily repair "broken" GIS polygons, and that according to the international standards ISO 19107 (Geographic information -- Spatial schema). In brief, given a polygon, it automatically repairs it and returns back a valid polygon (actually a MultiPolygon if the input represents more than one polygon). Note that this project is only concerned with single polygons, if you're interested in validating how different polygons interact with each others (to be precise: to check if they form a planar partition) have a look at our other project pprepair.

Automated repair methods can be considered as interpreting ambiguous or ill-defined polygons and giving a coherent and clearly defined output. Examples of errors are: polygon has a dangling edge; polygon is not closed; polygon self-intersects; an inner ring of the polygon is located outside the outer ring; etc.

prepair performs more or less the same as the new PostGIS 2.0's function ST_MakeValid(), but is faster, scales better to massive polygons, and predicting its behaviour is simple (so one can guess how her polygons will be repaired). We have implemented two repair paradigms: an extension of the odd-even algorithm to handle GIS polygons containing inner rings and degeneracies; and one where we follow a set difference rule for the rings.

prepair is based on a constrained triangulation (CGAL is used) and OGR is used to read/write WKT.

It is available under a dual license scheme: GPLv3 and commercial. If you are interested in a commercial license, please contact Ken Arroyo Ohori.

Details

Details of how we automatically repair broken polygons, and what results you can expect, are available in our Agile 2012 paper and the accompanying slides.

How to compile?

prepair is provided as source code, which is very easy to compile it on Linux and Mac. We plan on offering binaries (including for Windows) in the future.

To compile it, you first need to install the following three (free) libraries:

  1. CGAL
  2. OGR
  3. CMake

Afterwards run:

$ cmake .
$ make

It's a command-line program only

A WKT or an OGR dataset (shapefile, geojson or GML for instance) is read as input, and a WKT or a shapefile (a MultiPolygon) is given as output:

$ ./prepair --wkt 'POLYGON((0 0, 0 10, 10 0, 10 10, 0 0))'  
MULTIPOLYGON (((0 10,0 0,5 5,0 10)),((5 5,10 0,10 10,5 5)))  

$ ./prepair --ogr myfile.shp
MULTIPOLYGON (((0 10,0 0,5 5,0 10)),((5 5,10 0,10 10,5 5)))

$ ./prepair --shpOut --ogr data/CLC2006_180927.geojson 
Creating out.shp

Snap rounding of the input segments can be performed:

$ /prepair --isr 2 --wkt "POLYGON((0 0, 10 0, 15 5, 10 0, 10 10, 0 10, 0 0))"
MULTIPOLYGON (((11 1,11 11,1 11,1 1,11 1)))

It's possible to remove small (sliver) polygons in the output by giving the smallest area allowed:

$ ./prepair --wkt 'POLYGON((0 0, 10 0, 10 11, 11 10, 0 10))' 
MULTIPOLYGON (((10 0,10 10,0 10,0 0,10 0)),((11 10,10 11,10 10,11 10)))

$ ./prepair --wkt 'POLYGON((0 0, 10 0, 10 11, 11 10, 0 10))' --minarea 1
Removing polygons smaller than 1 unit^2.
MULTIPOLYGON (((10 0,10 10,0 10,0 0,10 0)))

Examples of invalid input you can try

The folder 'data' contains examples of relatively big invalid polygons. These are from the Corine Land Cover 2006 dataset.

A 'bowtie' polygon:

POLYGON((0 0, 0 10, 10 0, 10 10, 0 0))

Square with wrong orientation:

POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))

Inner ring with one edge sharing part of an edge of the outer ring:

POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 2,5 7,10 7, 10 2, 5 2))

Dangling edge:

POLYGON((0 0, 10 0, 15 5, 10 0, 10 10, 0 10, 0 0))

Outer ring not closed:

POLYGON((0 0, 10 0, 10 10, 0 10))

Two adjacent inner rings:

POLYGON((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 1 8, 3 8, 3 1, 1 1), (3 1, 3 8, 5 8, 5 1, 3 1))

Polygon with an inner ring inside another inner ring:

POLYGON((0 0, 10 0, 10 10, 0 10, 0 0), (2 8, 5 8, 5 2, 2 2, 2 8), (3 3, 4 3, 3 4, 3 3))

prepair's People

Contributors

hugoledoux avatar kenohori avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.