This uses raster::buffer(..., width = 0) internally, which fixes some failures to rgeos::gIsValid

# S3 method for SpatialPolygons
fixErrors(x, objectName = NULL,
  attemptErrorFixes = TRUE,
  useCache = getOption("reproducible.useCache", FALSE), ...)

Arguments

x

A SpatialPolygons object

objectName

Optional. This is only for messaging; if provided, then messages relayed to user will mention this.

attemptErrorFixes

Will attempt to fix known errors. Currently only some failures for SpatialPolygons* are attempted. Notably with raster::buffer(..., width = 0). Default TRUE, though this may not be the right action for all cases.

useCache

Logical, default getOption("reproducible.useCache", FALSE), whether Cache is used on the internal raster::buffer command.

...

Passed to methods. None currently implemented.