Convert lazysf to an in memory data frame or sf object
# S3 method for tbl_SFSQLConnection st_as_sf(x, ...) collect(x, ...)
x | output of |
---|---|
... | passed to |
An object of class function
of length 1.
a data frame from collect()
, sf data frame from st_as_sf()
(only if it contains an sfc
geometry column)
collect()
retrieves data into a local table, preserving grouping and ordering.
st_as_sf()
retrieves data into a local sf data frame (will succeed only if there is a geometry column of class sfc
)
lazysf
f <- system.file("gpkg/nc.gpkg", package = "sf", mustWork = TRUE) lsf <- lazysf(f) %>% dplyr::select(AREA, FIPS, geom) %>% dplyr::filter(AREA < 0.1) st_as_sf(lsf)#> Simple feature collection with 34 features and 2 fields #> geometry type: MULTIPOLYGON #> dimension: XY #> bbox: xmin: -84.03086 ymin: 34.06203 xmax: -75.45698 ymax: 36.57286 #> geographic CRS: NAD27 #> # A tibble: 34 x 3 #> AREA FIPS geom #> <dbl> <chr> <MULTIPOLYGON [°]> #> 1 0.061 37005 (((-81.23989 36.36536, -81.24069 36.37942, -81.26284 36.40504, -… #> 2 0.07 37053 (((-76.00897 36.3196, -76.01735 36.33773, -76.03288 36.33598, -7… #> 3 0.097 37091 (((-76.74506 36.23392, -76.98069 36.23024, -76.99475 36.23558, -… #> 4 0.062 37029 (((-76.00897 36.3196, -75.95718 36.19377, -75.98134 36.16973, -7… #> 5 0.091 37073 (((-76.56251 36.34057, -76.60424 36.31498, -76.64822 36.31532, -… #> 6 0.072 37181 (((-78.49252 36.17359, -78.51472 36.17522, -78.51709 36.46148, -… #> 7 0.053 37139 (((-76.29893 36.21423, -76.32423 36.23362, -76.37242 36.25235, -… #> 8 0.081 37189 (((-81.80622 36.10456, -81.81715 36.10939, -81.82231 36.15786, -… #> 9 0.063 37143 (((-76.48053 36.07979, -76.53696 36.08792, -76.5756 36.10266, -7… #> 10 0.044 37041 (((-76.68874 36.29452, -76.64822 36.31532, -76.60424 36.31498, -… #> # … with 24 more rows