strip_geometry: Strip geometry column

View source: R/mapping.r

strip_geometryR Documentation

Strip geometry column

Description

Turns an sf object into a tibble and removes the geometry column.

Usage

strip_geometry(.sf, .name_repair = "universal")

Arguments

.sf

an sf object

.name_repair

Treatment of problematic column names:

  • "minimal": No name repair or checks, beyond basic existence,

  • "unique": Make sure names are unique and not empty,

  • "check_unique": (default value), no name repair, but check they are unique,

  • "universal": Make the names unique and syntactic

  • a function: apply custom name repair (e.g., .name_repair = make.names for names in the style of base R).

  • A purrr-style anonymous function, see rlang::as_function()

This argument is passed on as repair to vctrs::vec_as_names(). See there for more details on these terms and the strategies used to enforce them.

Details

This function improves on the sf_drop_geometry() in sf by turning the object into a tibble, rather than a data.frame.

Value

The original sf as a tibble and without the geometry column.

Examples

## Not run: 
sf <- tibble::tibble(
	incident_type = c("fire", "flood", "cyclone"),
	`Date start` = c("2020-08-13", "2020-09-17", "2020-10-24"),
	`Responsible officials` = c("Tom", "Bob", "Jenny"),
	lat = c(38.66, 18.3, 25.33),
	lon = c(143.3, 132.7, 140.2)
) %>%
	sf::st_as_sf(
		coords = c("lon", "lat"),
		crs = "+proj=longlat +datum=WGS84"
	)

strip_geometry(.sf = sf, .name_repair = "universal")

strip_geometry(.sf = sf, .name_repair = "minimal")

strip_geometry(.sf = sf, .name_repair = "check_unique")

strip_geometry(.sf = sf, .name_repair = janitor::make_clean_names)

## End(Not run)

baslat/sak documentation built on April 14, 2025, 4:14 p.m.