smart_as_sf {smartmap} | R Documentation |
Smartly convert an object to a simple features data frame
Description
Converts R objects to sf::sf objects, but supports a wider range of input data than sf::st_as_sf.
Usage
smart_as_sf(x, ...)
## Default S3 method:
smart_as_sf(x, ...)
## S3 method for class 'data.frame'
smart_as_sf(x, ...)
## S3 method for class 'character'
smart_as_sf(x, ...)
Arguments
x |
any of the following:
|
... |
ignored |
Value
an sf::sf data.frame
Note
smart_as_sf.default()
looks if an sf::st_as_sf()
,
sf::st_as_sfc()
or as_coord_matrix()
method exists for x
(in
that order). If you are a package developer and want to support smartmap
for a custom S3 class in your package, it is enough to provide one of these
methods.
Examples
smart_as_sf(data.frame(lat = c(1,2,3), longitude = c(3,4,5)))
smart_as_sf(c(1, 2))