clean_sf function

Clean a Simple Feature

Clean a Simple Feature

Subset columns, transform coordinates, and (or) crop the spatial extent of a simple feature.

clean_sf(x, cols = NULL, agr = NULL, crs = NULL, extent = NULL, type = NULL)

Arguments

  • x: 'sf' object. Simple feature.
  • cols: 'character' vector. Names indicating the columns to keep. Vector names are optional and used to rename columns.
  • agr: 'character' vector. Attribute geometry relationship, specifies for each non-geometry attribute column how it relates to the geometry, and can have one of following values: "constant", "aggregate", "identity". Where "constant" is used for attributes that are constant throughout the geometry, "aggregate" where the attribute is an aggregate value over the geometry, "identity" when the attributes uniquely identifies the geometry of particular thing. The default value assumes you don't know. If named, vector names should correspond to the non-geometry list-column columns of x.
  • crs: 'crs' object. Target coordinate reference system.
  • extent: 'bbox' object. Spatial extent (aka bounding box) used to crop the simple feature.
  • type: 'character' vector. For retured geometries of type "GEOMETRY" or "GEOMETRYCOLLECTION", the returned object will consist only of elements of the specified type, one of "POLYGON", "POINT", and "LINESTRING".

Returns

Returns an object of class 'sf'.

Author(s)

J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center