Functions for coercing an object to an sf_list class objects created by
vctrs::new_list_of()
and checking lists of sf objects. Any function with
the allow_list
parameter supports this type of input.
Usage
as_sf_list(
x,
nm = "data",
col = NULL,
crs = NULL,
clean_names = TRUE,
.name_repair = "check_unique",
call = caller_env()
)
new_sf_list(
x,
nm = "data",
col = NULL,
clean_names = TRUE,
.name_repair = "check_unique",
call = caller_env()
)
is_sf_list(x, ext = TRUE, allow_null = FALSE)
sf_list_rbind(x, ...)
map_as_sf_list(x, .f, ...)
map_as_sf(x, .f, ...)
Arguments
- x
An
sf
,sfc
, orbbox
object.- nm
For as_sf_list, name(s) for sf list; defaults to "data". If col is provided, the values of the grouping column are used as names.
- col
For as_sf_list, the name of the column used to group data if x is a sf object or used to group and nest data before passing to x.
- crs
A character or numeric reference to a coordinate reference system supported by
sf::st_crs()
or anothersf
,sfc
, orbbox
object that is used to provide crs.- clean_names
If
TRUE
, clean names provided to nm or created based on value of col using janitor::clean_names. IfFALSE
, use names as provided.- .name_repair
One of "unique", "universal", or "check_unique". See
vctrs::vec_as_names()
for the meaning of these options.- call
The execution environment of a currently running function, e.g.
caller_env()
. The function will be mentioned in error messages as the source of the error. See thecall
argument ofabort()
for more information.- ext
If
TRUE
, check if x is asf
,sfc
, orbbox
class object or not; defaults toFALSE
. (used by is_sf)- allow_null
If
TRUE
and x isNULL
, returnTRUE
; defaults toFALSE
.- ...
For
sf_list_rbind()
, additional parameters passed topurrr::list_rbind()
. Formap_as_sf()
, additional parameters passed to map.- .f
A function, specified in one of the following ways:
A named function, e.g.
mean
.An anonymous function, e.g.
\(x) x + 1
orfunction(x) x + 1
.A formula, e.g.
~ .x + 1
. You must use.x
to refer to the first argument. Only recommended if you require backward compatibility with older versions of R.A string, integer, or list, e.g.
"idx"
,1
, orlist("idx", 1)
which are shorthand for\(x) pluck(x, "idx")
,\(x) pluck(x, 1)
, and\(x) pluck(x, "idx", 1)
respectively. Optionally supply.default
to set a default value if the indexed element isNULL
or does not exist.