Skip to content

small shiny app to understand various to correct geometries

Notifications You must be signed in to change notification settings

defuneste/utile_comme_du_pq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Utile Comme du PQ

This used to be a small repo with few files I needed to grab(yeah for french reader I created it when people were hoarding toilette papers...) but I guess now it is more about checking polygons geometries! The goal is to make a small shiny app that help myself (and maybe other see here) understand how various algorithms and their implementations are used to correct non valid geometries.

The source of inspirations started with this great post from Paul Ramsey (see here and here) about a new implementation of MakeValid() in postGIS.

I tried to reproduce some of this post with R in erreur_topo.R but some are still missing.

What is a valid polygons ?

First I should clarified what is a valid polygons:

Polygons have the concept of validity. The rings of a valid polygon may only intersect at distinct points -- rings can't overlap, and they can't share a common boundary. A polygon whose inner rings partly lie outside its exterior ring is also invalid (p.38 PosGIS in Action)

This is specified by the Simple Features set of standard

List of tools that can be used

Tools inplemeted to correct geometries

sf::st_buffer(x, m)

A great way of "cleaning some mess" but sometimes it feels like we are hammering stuff!

Both have implementation of GEOS but {sf} can also use s2. The engine use in {sf} depend of your version of GEOS (currently mine is 3.10) and if you are using planar or spherical geometry.

Both implementation have the option to provide you with more insight (see reasons in st_make_valid and messages in makeValid()).

Github: https://github.com/baddstats/polyclip

It use clipper v1 now but maybe v2 at one point.

Implementation in {spatstat} is in the owin function:

polyclip works on closed polygon and take as input a list of x and y but the last vertex should not repeat the first (as in simple feature standard). It can also take a list of list for several polygons (see: ?polyclip::polyclip). Polygon B is created in the spatstat.geom::owin as a larger rectangle.

My implementation seems not to be perfect as converting to polyclip object to sf's class maybe bring some errors.

Automatically repair broken GIS polygons using constrained triangulation and returns back a valid polygon.

it can be find here or here

More about here the algorythm in this publication: Ledoux, H., Arroyo Ohori, K., and Meijers, M. (2014). A triangulation-based approach to automatically repair GIS polygons. Computers & Geosciences 66:121–131.

References:

1 Leo S., et Regina Obe. 2021. PostGIS in Action, Third Edition. Simon and Schuster.
2 https://en.wikipedia.org/wiki/Simple_Features
3 Hijmans R (2022). terra: Spatial Data Analysis. R package version 1.6-17, https://CRAN.R-project.org/package=terra.
4 Pebesma, E., 2018. Simple Features for R: Standardized Support for Spatial Vector Data. The R Journal 10 (1), 439-446, https://doi.org/10.32614/RJ-2018-009
5 Johnson A, Baddeley A (2019). polyclip: Polygon Clipping. R package version 1.10-0, https://CRAN.R-project.org/package=polyclip.
6 Dicko A (2020). prepr: Automatic Repair of Single Polygons. R package version 0.1.9000, https://gitlab.com/dickoa/prepr.

About

small shiny app to understand various to correct geometries

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages