You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems this function is relatively slow compared to creating a sf object from a data.frame. It takes about 6 seconds to convert 300000 points. The conversion through a data frame is considerably faster. I think this could be easily resolved by using points_cpp here:
. I don't seem to be able to label this issue as an enhancement but it is very much meant like that and not a bug. If desirable I can create a pull request.
require(sf)
#> Loading required package: sf#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1; sf_use_s2() is TRUE
require(sp)
#> Loading required package: spa<-SpatialPoints(cbind(runif(300000),runif(300000)), proj4string=CRS( "+proj=longlat"))
bench::mark(st_as_sfc(a),
st_as_sfc(st_as_sf(as.data.frame(a), coords=1:2, crs=st_crs(a))))[,1:3]
#> Warning: Some expressions had a GC in every iteration; so filtering is disabled.#> # A tibble: 2 × 3#> expression min#> <bch:expr> <bch:tm>#> 1 st_as_sfc(a) 5.61s#> 2 st_as_sfc(st_as_sf(as.data.frame(a), coords = 1:2, crs = st_crs(a))) 173.8ms#> # … with 1 more variable: median <bch:tm>
A (tested) PR would be great; as you can see #2059 has an alternative approach to this (making sfc_POINT much more like a SpatialPoint), but it's currently unclear whether we want to merge that.
It seems this function is relatively slow compared to creating a
sf
object from adata.frame
. It takes about 6 seconds to convert 300000 points. The conversion through a data frame is considerably faster. I think this could be easily resolved by usingpoints_cpp
here:sf/R/sp.R
Line 94 in 4f550e5
Created on 2022-12-14 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: