transform_sf()is similar tosf::st_transform()but supports sf, sfc, or bbox objects as the crs parameter, supports sfg objects (transformed to sfc), and usessf::st_set_crs()if the CRS for the provided object isNA. This function does not support bounding box transformations.relocate_sf_col()relocates the sf geometry column after specified column (by default after everything).rename_sf_col()a wrapper forsf::st_set_geometry()that renames the sf column.get_sf_col()returns the "sf_column" attribute.get_sf_colnames()returns the column names of a file that can be read withsf::read_sf()to allow you to use column names to build a query (or provide a value for name_col) without reading the whole file.
Usage
transform_sf(x, crs = NULL, allow_null = TRUE, ...)
relocate_sf_col(x, .after = dplyr::everything())
rename_sf_col(x, sf_col = "geometry")
get_sf_col(x = NULL)
get_sf_colnames(x = NULL, dsn = NULL, layer = NULL, ...)Arguments
- x
A
sforsfcobject. If x has a missing crs, the crs is set to the provided value.- crs
A coordinate reference system identifier (numeric or character) or a
sf,sfc,bbox, orcrsclass object supported bysf::st_crs().- allow_null
If
TRUEand crs isNULL, return x.- ...
Additional parameters passed to
sf::st_transform()bytransform_sf()or tosf::read_sf()byget_sf_colnames()if x is notNULL.- .after
The location to place sf column after; defaults to
dplyr::everything().- sf_col
Name to use for the sf column after renaming; defaults to "geometry".
- dsn
data source name (interpretation varies by driver - for some drivers,
dsnis a file name, but may also be a folder, or contain the name and access credentials of a database); in case of GeoJSON,dsnmay be the character string holding the geojson data. It can also be an open database connection.- layer
layer name (varies by driver, may be a file name without extension); in case
layeris missing,st_readwill read the first layer ofdsn, give a warning and (unlessquiet = TRUE) print a message when there are multiple layers, or give an error if there are no layers indsn. Ifdsnis a database connection, thenlayercan be a table name or a database identifier (seeId). It is also possible to omitlayerand rather use thequeryargument.
