We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sfc_to_df()
I wonder if it would be resonable to only return X and Y coordinates for points when converting geometry to data frame like sf::st_coordinates() does?
sf::st_coordinates()
library("sf") library("sfheaders") n = 100000 df = data.frame(x = rnorm(n), y = rnorm(n)) pts = st_as_sfc(st_as_sf(df, coords = c("x", "y"))) x = sf::st_coordinates(pts) str(x) #> num [1:100000, 1:2] -0.4177 -0.0679 0.6598 0.756 0.1694 ... #> - attr(*, "dimnames")=List of 2 #> ..$ : NULL #> ..$ : chr [1:2] "X" "Y" format(object.size(x), units = "auto") #> [1] "1.5 Mb" y = sfheaders::sfc_to_df(pts) str(y) #> 'data.frame': 100000 obs. of 4 variables: #> $ sfg_id : int 1 2 3 4 5 6 7 8 9 10 ... #> $ point_id: int 1 2 3 4 5 6 7 8 9 10 ... #> $ x : num -0.4177 -0.0679 0.6598 0.756 0.1694 ... #> $ y : num -0.71246 -0.00779 -2.32569 -0.14325 2.83237 ... format(object.size(y), units = "auto") #> [1] "2.3 Mb" t = bench::mark( check = FALSE, sf = st_coordinates(pts), sfheaders = sfc_to_df(pts), ) t[, 1:5] #> expression min median `itr/sec` mem_alloc #> 1 sf 1.72ms 1.78ms 532. 3.05MB #> 2 sfheaders 28.15ms 29.07ms 34.1 4.2MB
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I wonder if it would be resonable to only return X and Y coordinates for points when converting geometry to data frame like
sf::st_coordinates()
does?The text was updated successfully, but these errors were encountered: