Skip to contents

Inverse of clip_to_dataframe(). Takes the flat data frame stored in a BirdFlow object's metadata$clip$polygon slot and rebuilds an sf polygon. Factored out of get_clip() so the round-trip (polygon -> data frame -> polygon) can be exercised in tests without constructing a full BirdFlow object.

Usage

dataframe_to_clip(df, crs = NA)

Arguments

df

A data frame as produced by clip_to_dataframe() with columns id, part, x, y, and hole. The hole column is the integer ring index (0 for outer rings, 1..N for each distinct hole within a part); legacy logical values are coerced via as.integer().

crs

Coordinate reference system. Accepts anything terra::vect() accepts (a WKT string, an "EPSG:..." code, an sf::st_crs() object, or NA for no CRS).

Value

An sfc polygon (geometry only, no attributes).