Closed
Description
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:
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: sp
a<-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>
Created on 2022-12-14 with reprex v2.0.2
Metadata
Metadata
Assignees
Labels
No labels