Closed SymbolixAU closed 6 years ago
Thanks for the suggestion! In fact we have discussed alternatives and I ran a benchmarks showing geojsonio is no faster, if not slightly slower, than sf.
This geojsonsf** pkg seems blazing fast. Question: how is it so fast? For producing geojson representations of sf objects I imagine it's unbeatable. Great work, we'll consider it for sure.
Question: how is it so fast?
Everything's written in C++ / Rcpp, whereas geojsonio is all R.
For producing geojson representations of sf objects
This is exactly why I wrote it. I do a lot of work with spatial databases and needed a quick way to read & write.
Sounds good. Just noticed my previous comment was borked. Here's a link to the benchmark I ran with the same thing in mind: https://github.com/ATFutures/geoplumber/issues/27#issuecomment-421247231
I reckon we'll switch to geojsonsf
. Thanks for sharing.
Thank you @SymbolixAU. Thanks @Robinlovelace.
C++ is convincing, and will do.
system.time(geojsonio::geojson_json(geoplumber::traffic))
#> user system elapsed
#> 0.973 0.046 1.021
system.time(geojsonsf::sf_geojson(geoplumber::traffic))
#> user system elapsed
#> 0.008 0.001 0.009
Created on 2018-09-16 by the reprex package (v0.2.0).
# for now leaving the traffic data to be parsed every run.
time curl http://localhost:8000/api/data
# geojsonsf
real 0m0.046s
user 0m0.007s
sys 0m0.006s
#geojsonio
real 0m0.448s
user 0m0.008s
sys 0m0.013s
Committing.
Awesome fast work @layik. From kitchen surrounded by hung-over people. Showing the guests here the power of geographic data science!
If there's any features you want (such as adding an attr(x, "class") <- "json"
or something let me know on my issues page
Also be aware of this one where elevation isn't supported yet
Thanks for letting us know. I will watch out for the elevation. Right now, 2D is doing ok.
@Robinlovelace @layik I've found another issue you should be aware of, and this one is a bit more serious
https://github.com/SymbolixAU/geojsonsf#warning-note-2018-09-22
I've submitted an update to rapidjsonr
, so should be able to publish and update to geojsonsf
in a day or so.
Thanks for letting us know @SymbolixAU, will definitely watch out for it.
@Robinlovelace @layik So I can plan my updates to geojsonsf
, what are your timelines for release of geoplumbr?
I've been working on a new JSON converter (jsonify) which, when complete, should make the conversion from sf
to GeoJSON faster. But It won't be ready for a couple (2-4) weeks yet.
At least month of testing/feedback before we submit it to cran is my guess. Layik is the main person behind it tho so with getting his view 2.
I just added two milestones, apologies to you both @SymbolixAU and @Robinlovelace been working on something else (very cool). So hopefully that gives us some rough timelines.
@layik thanks. I'll work to getting geojsonsf
updated in mid-October.
Will it break any of your code if I make all the GeoJSON returned from sf_geojson() / sfc_geojson()
have a "json" class attribute (it currently returns chracter
)?
sfc_geojson(sf::st_sfc(sf::st_point(c(0,0))))
# [1] "{\"type\":\"Point\",\"coordinates\":[0.0,0.0]}"
# attr(,"class")
# [1] "json"
I've also resolved a lot of issues ready for v1.2.
Of note is is handling elevation (Z/M) attributes, dates, and speed improvement for converting sf -> GeoJSON.
If it breaks any of your tests please let me know. I'm aiming for a 31st October release.
I should re-enable email notifications. Apologies @SymbolixAU for late reply. No, it won't.
I have patched current issue with adding an empty property to the df before converting it to GeoJSON. Awesome work RE new issues for v1.2!
Let me know if I can be of any other help.
Dear @SymbolixAU, with both geojsonsf
and now considering jsonify
, I am hitting the block that I either use both geojsonio
and jsonlite
in parallel or I am struggling to do my reads both from disk and remote paths. Do you suggest a way forward for now? Use geojsonio
for read and geojsonsf
for conversion?
Thank you!
@layik I'm not sure I understand your question. Do you need a way to read a geojson file from disk?
@SymbolixAU indeed or best, one that would take a remote URL or a local path, the equivalent of geojsonio::geojson_read()
function.
geojson_sf()
can read urls
from ?geojson_sf
Arguments geojson | string or vector of GeoJSON, or a URL or file pointing to a geojson file
i.e.
wpz <- geojsonsf::geojson_sf("http://opendata.canterburymaps.govt.nz/datasets/fb00b553120b4f2fac49aa76bc8d82aa_26.geojson")
works
Oh! You guys need some docs work, and I apologize if I cannot send a PR. I did search for read!
Testing local paths.
Interesting! That gives me an sf
data.frame
class. I have unfinished code to do that and you guys have done it. Thank you.
There's just one thing missing, but I don't think it prevents the object from being valid sf
Well, I will cross that bridge when I get there. No idea what it is. Thank you for being around!
I realise this package is still in development, but I'd like to suggest using
geojsonsf
overgeojsonio
for speedOn the example data
uol
on something bigger