Skip to contents

Checks whether the geometries of the shapes specified via tm_shape() are valid. Invalid geometries can cause errors or maps with artifacts.

Usage

tm_check_fix()

Value

A tmap element.

Details

This tmap element checks the geometries with sf::st_is_valid() and, if needed, applies sf::st_make_valid(). If that is unsuccessful, it toggles the s2 backend of the sf package (on or off, depending on whether it was already enabled) and tries again. If the geometries are still invalid, the map is drawn with a warning and the invalid geometries are removed.