Learn R Programming

scenfire (version 0.1.0)

cleanse_duplicates: Remove Duplicate Polygons from Candidate Set

Description

This function checks a set of candidate polygons and removes duplicates based on spatial equality. It iteratively removes duplicated polygons until none remain.

Usage

cleanse_duplicates(candidates)

Value

An sf object with duplicate polygons removed. The function also prints messages to the console indicating whether duplicates were found and their indices.

Arguments

candidates

An sf object containing candidate polygons.

Details

Duplicates are detected using sf::st_equals(), which checks for geometric equality between polygons. The function continues removing duplicates until no further matches are found.

See Also

Examples

Run this code
library(sf)

# Create a simple sf object with duplicate polygons
poly1 <- st_polygon(list(rbind(c(0,0), c(1,0), c(1,1), c(0,1), c(0,0))))
poly2 <- st_polygon(list(rbind(c(0,0), c(1,0), c(1,1), c(0,1), c(0,0)))) # duplicate
poly3 <- st_polygon(list(rbind(c(2,2), c(3,2), c(3,3), c(2,3), c(2,2))))

candidates <- st_sf(geometry = st_sfc(poly1, poly2, poly3))

cleansed <- cleanse_duplicates(candidates)

Run the code above in your browser using DataLab