ATFutures / geoplumber

Serve geographic data from R and consume with scalable front end.
https://atfutures.github.io/geoplumber/
59 stars 7 forks source link

Reading from URL #53

Closed SymbolixAU closed 5 years ago

SymbolixAU commented 5 years ago

In this line you're reading the GeoJSON, converting to sf, then converting back to GeoJSON.

In summary:

url <- "http://opendata.canterburymaps.govt.nz/datasets/fb00b553120b4f2fac49aa76bc8d82aa_26.geojson"
geojson <- geojsonsf::geojson_sf(url)
geojson <- geojsonsf::sf_geojson(geojson)

Would it be more performant to directly read the GeoJSON and leave it as-is, rather than round-tripping to sf and back?

geo <- readLines(url)
layik commented 5 years ago

Thanks @SymbolixAU why did I miss this? It is because we have something more urgent here. Appreciate the input.

To answer your question: The rason is that geoplumber is trying to serve the data from internal api endpoints, we discussed this, as you rightly ask, we could probably just read it and dump it to the body of the response object here. I will test and update this issue.

It seems gp_geojson has no issue reading both from a local path or a remote URL.

Thanks guys!

layik commented 5 years ago
geo <- readLines(url)
geo <- paste(geo, collapse = "")

Seems to work, the reason for this collapsing cropped up before, it is to do with underlying packages of plumber. But as I do more tests might push and close this.

One more time, thanks a lot.

SymbolixAU commented 5 years ago

yes, that's exactly what I do here too - paste0(readLines(url), collapse = "")

layik commented 5 years ago

So far all good. Closing and appreciate all your input @SymbolixAU. geojsonsf has made things quite different for me.