Skip to content
Emmanuel Blondel edited this page Apr 14, 2017 · 6 revisions

cleangeo - Cleaning geometries from spatial objects in R

cleangeo provides a set of utility tools to inspect spatial objects, facilitate handling and reporting of topology errors and geometry validity issues. Finally, it provides a geometry cleaner that will fix all geometry problems, and eliminate (at least reduce) the likelihood of having issues when doing spatial data processing.


With the aim to guarantee the sustainability of cleangeo, cleangeo is currently seeking for institutional or individual sponsors to fund the package development in order to (1) enhance and strenghten existing functionalities, (2) provide new features, and (3) ensure timeley maintenance and users support.

If you wish to sponsor cleangeo, do not hesitate to contact me


For citation, please use the DOI DOI

Do you need support to use cleangeo? You may consider to:

Do you use cleangeo? your feedback is welcome! You may consider to:

  • report a bug
  • send suggestions either by email

Table of contents

1. Overview
2. Package status
3. Success stories
4. Credits
5. Fundings
6. User guide
6.1 Install cleangeo
6.2 Inspect spatial objects
6.3 Clean spatial objects
7. Issue reporting

1. Overview and vision


R provides a lot of facilities to read and manipulate spatial data. We can mention some packages such as:

The main problem comes when spatial objects do not have valid geometries, or expose different types of geometry errors (e.g. orphaned holes), which prevents any easy spatial data processing.

cleangeo was built in order:

  • to facilitate handling and catching rgeos geometry issues
  • to provide a tool to clean and validate the spatial objects, prior any geoprocessing

2. Development status


Build Status CRAN_Status_Badge Github_Status_Badge

Check the [Change History] (https://github.com/eblondel/cleangeo/wiki/Change-History) which provides a list of fixes and improvements by milestone.

Check also the success stories to see how and where cleangeo is used!

3. Success stories


While the cleangeo is still growing, it is worth mentioning that its user community is growing, and positive feedback and acknowledgments were provided about its use. Support was provided to users either by supplying examples and help or even by improving the package (enhancements, bug fixing).

Some projects using cleangeo:

4. Credits


Did you use cleangeo in your work?

We would be very grateful if you can add a citation in your published work. By citing cleangeo, beyond acknowledging the work, you contribute to make it more visible and guarantee its growing and sustainability. For this, please use the DOI DOI

5. Project Fundings


The cleangeo package is borned from a volunteer development initiative to facilitate cleaning of geometries from spatial objects in R, hence to allow a better and more accurate geoprocessing when performing geospatial analyses.

Currently, the project is seeking for funding opportunities in order to make the package growing with new functionalities, improvements, guarantee a quality maintenance of the R package and users support, hence ensuring the sustainability of the cleangeo project. If you wish to make a donation to acknowledge for the work accomplished so far, please contact us.

6. User guide


6.1 How to install cleangeo in R

Package can be installed either from Github (latest)

install.packages("devtools")

Once the devtools package loaded, you can use the install_github to install cleangeo. By default, package will be installed from master which is the current version in development (likely to be unstable).

require("devtools")
install_github("eblondel/cleangeo")

The latest release can be installed by the specifying the name of the release as ref value in install_github. See https://github.com/eblondel/cleangeo/releases for the list of releases (note: a release is generally made when package is published to CRAN).

require("devtools")
install_github("eblondel/cleangeo", ref= "v0.1-2")

6.2 Inspecting geometries from spatial objects

Let's load some sample data in R:

require(maptools)
file <- system.file("extdata", "example.shp", package = "cleangeo")
sp <- readShapePoly(file)

cleangeo first allows to inspect spatial objects, and detect eventual issues:

sp.report <- clgeo_CollectionReport(sp)
sp.summary <- clgeo_SummaryReport(sp.report)

The output indicates that 2 spatial objects have a problem of geometry validity.

6.2 Cleaning geometries from spatial objects

Cleaning spatial objects is very easy:

sp.fixed <- clgeo_Clean(sp, verbose = TRUE)

Let's analyse the new spatial objects:

sp.fixed.report <- clgeo_CollectionReport(sp.fixed)
sp.fixed.summary <- clgeo_SummaryReport(sp.fixed.report)

And that's it! Now your spatial objects have clean geometries, you can safely do some spatial data processing on it.

7. Issue reporting


Issues can be reported at https://github.com/eblondel/cleangeo/issues