tm_check_fix: Check and fix invalid geometries

View source: R/tm_layout.R

tm_check_fixR Documentation

Check and fix invalid geometries

Description

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()

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.

Value

A tmap element.


tmap documentation built on June 26, 2026, 5:08 p.m.