Learn R Programming

frheritage (version 0.1.0)

geo_object_check: Check that spatial objects are valid sf layers with expected geometry type

Description

This internal helper verifies that all provided objects:

  • are of class sf (optional, controlled by check_class);

  • contain valid geometries (sf::st_is_valid());

  • contain no empty geometries (!sf::st_is_empty());

  • have a geometry type among the allowed ones (if specified).

Usage

geo_object_check(
  ...,
  check_class = TRUE,
  check_valid = TRUE,
  check_empty = TRUE,
  allowed_geom_classes = "POLYGON"
)

Value

Invisibly returns NULL. Throws an error if any object fails validation.

Arguments

...

One or several spatial objects to test.

check_class

Logical. Whether to check that each object inherits from class sf. Default is TRUE.

check_valid

Logical. Whether to check that geometries are valid. Default is TRUE.

check_empty

Logical. Whether to check that geometries are not empty. Default is TRUE.

allowed_geom_classes

Character vector of allowed geometry types (e.g., "POLYGON", "LINE", "POINT"). If NULL, the geometry type is not checked. Default is "POLYGON".

Details

The function raises an informative error message if any condition fails. It is intended for internal validation of sf inputs before performing geometric operations or API queries.

Geometry type validation is performed via geo_object_type(), which ensures type consistency across geometries.

See Also

geo_object_type()