ropensci/osmdata

Add function to convert ways to data frame

Closed this issue · 3 comments

For routing purposes, it'll be necessary to read an osmdata object and extract all ways as a single data.frame of [from_id, to_id, from_x, to_x, distance].

cc @karpfen

This issue resolved with function currently parked in osmprob, which takes an sf collection of LINESTRING objects (or an entire osmdata object), and returns a data.frame of all pairwise to-from connections in the network. This enables direct conversion to an igraph or anything else needed for routing purposes.

Now a question for @Robinlovelace @masalmon : I'd see this as a pretty useful enhancement to osmdata, but would like your thoughts first. I admit that it has no ready place in the current structure of osmdata functions, so feel free to criticise. (Potential integration will come post-ropensci-review, to keep the package as simple as possible for the moment.)

I think it's great to start having helper functions like that. E.g. maybe I could add a function for calculating the total distance of one element. I guess we could call this sort of functions "wrangle/transform output data" or something like that?

although maybe some people could argue this should go into a second package? Then there'd be an ecosystem of osmdata packages with osmdata, osmplotr and osmdata.utils or something like that.

This now exists as dodgr::weight_streetnet(). That function currently returns a data.frame, but will be extended soon to return a silicate::SC object.