-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
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
sf::st_as_text()
is slow
#2361
Comments
Yes, maybe we could add pointers to alternatives (lwgeom) in the docs; Use Sys.setenv("LWGEOM_WKT"="true") to have |
I also think it would be good idea to mention Line 20 in 8bf890e
Maybe if we add |
The change to default to using lwgeom is a lot of work, as the WKT produced changes and many tests in |
Yeah, adding x = seq_len(1e6)
fun = function(x) {
output = double(length(x))
for (i in seq_along(x)) output[i] = sqrt(x[i])
return(output)
}
bench::mark(
sapply(x, sqrt),
vapply(x, sqrt, double(1)),
fun(x)
)
# expression min median `itr/sec` mem_alloc
# 1 sapply(x, s… 418.4ms 489ms 2.04 30.89MB
# 2 vapply(x, s… 292.5ms 300.6ms 3.33 7.63MB
# 3 fun(x) 46.7ms 47.2ms 20.7 7.63MB |
Feel free to try out, I would be surprised if that would reduce time meaningfully. |
Should I prepare PR with changes in documentation or would you rather do it yourself? |
FWIW, in a previous job we took sf objects and casted the geometry column to WKT to upload into snowflake. We ran into this problem and the solution was to use |
enhance `st_as_text()` docs (for #2361)
It seems that
sf::st_as_text()
is definitely slower than its alternatives available in{lwgeom}
and{terra}
.The text was updated successfully, but these errors were encountered: