CRAN_Status_Badge Github_Status_Badge cran checks DOI

cleangeo provides utilities to clean geometries from spatial objects in R. If you aim to do geoprocessing in R, this package will help you in cleaning your Spatial* objects before, and avoid geoprocessing errors later.

Note on cleangeo archiving process (after version 0.3), needs/prerequisites to move to sf

The_ cleangeo package was developed in 2015 at at time where sp and rgeos, maptools, raster, etc. were among R solutions to deal with spatial data handling. With the increase of sf instead of sp objects, it’s recommended to switch progressively to sf as base for handling spatial features, and to use sf::st_make_valid to validate geometries (which is now the default in cleangeo). Following the archiving of rgeos, maptools, it is probable that cleangeo may also be archived.

Native geometry fixing strategies, although applicable in some cases, do not cover the full typology of geometry issues we may find with vector data. Although refactored to remove the dependency with rgeos and maptools, some unexpected behaviors can be found.

With the progress done on validating geometries, especially with sf, the default strategy to fix geometries in cleangeo has now been switched to the use of sf::st_make_valid.

Nonetheless, although the original set-up and actual name of sf refers to an ISO/OGC specification (Simple Features), users that handle geospatial data with tools that rely on the ISO/OGC realm (most of GIS tools, from the OsGeo or even proprietary software) should use sf cautiously as the default behavior doesn’t rely anymore on the ISO/OGC realm for managing geographic coordinates (it was initially) but on a non-standard technology-specific geometry model handled with s2 (from the name of the library developed by Google). To turn off this default set-up, and to conserve legacy behaviors (backward-compatibility) in geospatial processes, users will need to ensure they use sf::sf_use_s2(FALSE). This is particularly needed if you grab data from OGC data services (eg. with ows4R), and related OGC formats that do not rely on the s2 data model, but on the ISO/OGC Simple Features data model.


We thank in advance people that use cleangeo for citing it in their work / publication(s). For this, please use the citation provided at this link DOI

Use cases

Some projects using cleangeo: