Skip to contents

Apply sf::st_make_valid() to invalid ROIs, drop duplicate consecutive vertices, re-orient holes that wind like their exterior ring, and clip out-of-bounds geometry to the image bounds (an intersection, so a polygon stays a polygon), reporting what changed.

Usage

at_fix_geometry(project, verbose = TRUE, call = rlang::caller_env())

Arguments

project

An annot_project.

verbose

Logical; whether to report repairs. Default TRUE.

call

The calling environment, for error reporting.

Value

The annot_project with repaired geometry. Repairs are reported via cli::cli_inform() when verbose is TRUE. Issues that cannot be repaired (zero area, degenerate, empty, NA coordinates, or a clip that would leave nothing inside the image) are left in place and reported.