I have a bunch of polygons representing land cover classes, however I don't need this much detail. I would like to merge small polygons (ie < 150m2) with it's largest neighbour. This would be similar to "Eliminate" in ArcGIS Pro or "eliminate selected polygons" in QGIS. This process will be repeated so I'd like to script it in R and save some time.
The only way I could think to do it was to add a column indicating which polygons were under 150m2, then somehow merging them to nearest neighbour.
#Packages
library(terra)
library(sf)
library(dplyr)
#Adding polygons from Terra and converting to sf
v <- vect(system.file("ex/lux.shp", package="terra"))
v <- st_as_sf(v[c(1:12)])
#Adding a column indicating which polygons are under 150m2
mutate(v, area_thresh = case_when(AREA < 150 ~ 1,
AREA > 150 ~ 0))