consider geojsonsf
- Dominant language
- R
- Stars
- 49
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
I see you're using `geojsonio` to convert `sf` objects to GeoJSON. Would you consider using [`geojonsf`](https://github.com/SymbolixAU/geojsonsf) to improve speed?
Hopefully in this benchmark I'm replicating what you're doing inside [topogram](https://github.com/dreamRs/topogram/blob/6b3d1b66fbaadc273eaacc60780c4335daf194ae/R/topogRam.R#L159)
```r
library(microbenchmark)
library(geojsonsf)
library(geojsonio)
microbenchmark(
geojsonsf = {
shape$id <- 1:nrow(shape)
sf_geojson( shape )
},
geojsonio = {
geo_list <- geojson_list(input = shape)
for (i in seq_along(geo_list$features)) {
geo_list$features[[i]]$id <- i - 1
geo_list$features[[i]]$properties$id <- i - 1
}
geo_json <- geojson_json(input = geo_list)
},
times = 5
)
# Unit: milliseconds
# expr min lq mean median uq max neval
# geojsonsf 1.955478 2.078431 2.172361 2.126749 2.226844 2.474302 5
# geojsonio 235.419525 239.354627 241.348199 240.610821 242.299392 249.056631 5
```
Note, I'm planning an update to `geojsonsf` by the end of October with some important fixes & updates.
---
You can also specify package version dependencies inside the `DESCRIPTION` in place of inside functions
```r
if (packageVersion("geojsonio") < "0.6.0.9100")
stop("You need geojsonio >= 0.6.0.9100 to use this function.", call. = FALSE)
```
vs
```
Imports:
htmlwidgets,
geojsonio (>=0.6.09100),
htmltools,
shiny,
rmarkdown,
jsonlite,
magrittr
```
This way you don't have to implement the version check inside each function which may require it.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.